You are here

function ife_form_alter in Inline Form Errors 7.2

Same name and namespace in other branches
  1. 6.2 ife.module \ife_form_alter()
  2. 6 ife.module \ife_form_alter()
  3. 7 ife.module \ife_form_alter()

Implements hook_form_alter().

File

./ife.module, line 175
Drupal hooks.

Code

function ife_form_alter(&$form, &$form_state, $form_id) {
  $status = variable_get('ife_show_everywhere', 0);
  if ($status && !in_array($form_id, _ife_blacklist())) {
    $ife_options = new stdClass();
    $ife_options->status = TRUE;
    $ife_options->display = -1;
  }
  else {
    $ife_options = ife_form_id_load($form_id);
  }
  if ($ife_options && $ife_options->status) {
    $display = ife_form_id_display($ife_options);
    $form['#ife_display'] = $display;

    // Commerce checkout.
    if (strpos($form_id, 'commerce_checkout_form') !== FALSE) {
      $form['buttons']['continue']['#validate'][] = 'ife_form_validator';
    }
    else {
      $form['#validate'][] = 'ife_form_validator';
    }
  }

  // Print form_ids.
  if (variable_get('ife_show_form_ids', 0)) {
    $form['ife_form_id'] = array(
      '#markup' => t('Form ID: @form_id', array(
        '@form_id' => $form_id,
      )),
      '#weight' => -1000,
      '#access' => user_access('administer inline form errors'),
    );
  }
}