You are here

function clientside_validation_form_alter in Clientside Validation 7.2

Same name and namespace in other branches
  1. 8.2 clientside_validation.module \clientside_validation_form_alter()
  2. 8 clientside_validation.module \clientside_validation_form_alter()
  3. 6 clientside_validation.module \clientside_validation_form_alter()
  4. 7 clientside_validation.module \clientside_validation_form_alter()
  5. 3.0.x clientside_validation.module \clientside_validation_form_alter()
  6. 2.0.x clientside_validation.module \clientside_validation_form_alter()

Implements hook_form_alter().

File

./clientside_validation.module, line 267
Add client side validation to forms.

Code

function clientside_validation_form_alter(&$form, &$form_state, $form_id) {
  if (!clientside_validation_match_form($form_id)) {
    return;
  }
  if (strpos($form_id, 'webform_client_form') !== FALSE) {
    $definedsettings = clientside_validation_settings_load('webforms', $form['#node']->nid);
    $form['#clientside_validation_settings'] = $definedsettings;
    if (isset($form['actions']['previous'])) {
      $form['actions']['previous']['#attributes']['class'][] = 'cancel';
    }
  }
  else {
    if (isset($form['#node_edit_form']) && $form['#node_edit_form']) {
      $definedsettings = clientside_validation_settings_load('content-types', $form['#node']->type);
    }
    else {
      $definedsettings = clientside_validation_settings_load('custom-forms', $form_id);
    }
    $form['#clientside_validation_settings'] = $definedsettings;
    if (isset($form['actions']['delete'])) {
      $form['actions']['delete']['#attributes']['class'][] = 'cancel';
    }
  }
  $form['#after_build'][] = 'clientside_validation_form_after_build';
}