You are here

function i18n_form_alter_settings in Internationalization 6

Same name and namespace in other branches
  1. 5.3 i18n.module \i18n_form_alter_settings()
  2. 5 i18n.module \i18n_form_alter_settings()
  3. 5.2 i18n.module \i18n_form_alter_settings()

Check for multilingual variables in form.

1 call to i18n_form_alter_settings()
i18n_form_alter in ./i18n.module
Implementation of hook_form_alter();

File

./i18n.module, line 664
Internationalization (i18n) module.

Code

function i18n_form_alter_settings(&$form, &$variables) {
  $result = array();
  foreach (element_children($form) as $field) {
    if (count(element_children($form[$field])) && empty($form[$field]['#tree'])) {
      $result += i18n_form_alter_settings($form[$field], $variables);
    }
    elseif (in_array($field, $variables)) {

      // Add form field class: i18n-variable
      $form[$field]['#attributes']['class'] = !empty($form[$field]['#attributes']['class']) ? $form[$field]['#attributes']['class'] . ' i18n-variable' : 'i18n-variable';
      $form[$field]['#description'] = !empty($form[$field]['#description']) ? $form[$field]['#description'] : '';
      $form[$field]['#description'] .= ' <strong>' . t('This is a multilingual variable.') . '</strong>';

      // Addd field => name to result
      $result[$field] = !empty($form[$field]['#title']) ? $form[$field]['#title'] : $field;
    }
  }
  return $result;
}