You are here

function spaces_customtext_settings_validate in Spaces 7

Same name and namespace in other branches
  1. 6.3 spaces_customtext/spaces_customtext.admin.inc \spaces_customtext_settings_validate()
  2. 7.3 spaces_customtext/spaces_customtext.admin.inc \spaces_customtext_settings_validate()

Validation handler for custom strings. Actually acts as a form processor.

1 string reference to 'spaces_customtext_settings_validate'
spaces_customtext_settings_form in spaces_customtext/spaces_customtext.admin.inc
System settings form for custom text strings.

File

spaces_customtext/spaces_customtext.admin.inc, line 36

Code

function spaces_customtext_settings_validate(&$element, &$form_state) {
  $name = end($element['#parents']);

  // If "Reset" was hit, we only want to reset values for this particular
  // feature. Yank this feature's strings and preserve the rest by switching
  // $op to 'Save configuration'.
  $op = isset($form_state['values']['op']) ? $form_state['values']['op'] : '';
  if ($op == t('Reset to defaults')) {
    $form_state['values'][$name] = array_diff_key($element['#custom_strings'], $form_state['values'][$name]);
    $form_state['values']['op'] = t('Save configuration');
  }
  else {
    $form_state['values'][$name] = array_merge($element['#custom_strings'], $form_state['values'][$name]);
    $form_state['values'][$name] = array_filter($form_state['values'][$name], 'trim');
  }
}