You are here

function parallax_bg_admin_validate in Parallax Background 7

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

parallax_bg_admin()

File

./parallax_bg.module, line 166
Basic Module file.

Code

function parallax_bg_admin_validate($form, &$form_state) {
  if ($form_state['clicked_button']['#value'] == "Delete element") {
    $settings = variable_get('parallax_bg_settings');
    $child = $form_state['clicked_button']['#parents'][2];
    unset($settings['triggers_fieldset'][$child]);
    variable_set('parallax_bg_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/parallax_bg');
  }
}