You are here

function scrollreveal_admin_validate in Scroll Reveal 7

Same name and namespace in other branches
  1. 7.2 scrollreveal.module \scrollreveal_admin_validate()

Now we add a handler/function to validate the data entered into the "year of birth" field to make sure it's between the values of 1900 and 2000. If not, it displays an error. The value report is $form_state['values'] (see http://drupal.org/node/144132#form-state).

Notice the name of the function. It is simply the name of the form followed by '_validate'. This is always the name of the default validation function. An alternate list of validation functions could have been provided in $form['#validate'].

See also

scrollreveal_admin()

File

./scrollreveal.module, line 378
Basic Module file.

Code

function scrollreveal_admin_validate($form, &$form_state) {
  if ($form_state['clicked_button']['#value'] == "Delete element") {
    $settings = variable_get('scrollreveal_settings');
    $child = $form_state['clicked_button']['#parents'][2];
    unset($settings['triggers_fieldset'][$child]);
    variable_set('scrollreveal_settings', $settings);
    $form_state['rebuild'] = TRUE;
    $form_state['flag'] = 1;
    drupal_set_message(t('The element have been deleted.'));
    drupal_goto('admin/config/user-interface/scrollreveal');
  }
}