You are here

function ife_settings_form_validate in Inline Form Errors 7.2

Same name and namespace in other branches
  1. 6.2 ife.settings.inc \ife_settings_form_validate()
  2. 6 ife.settings.inc \ife_settings_form_validate()
  3. 7 ife.settings.inc \ife_settings_form_validate()

IFE settings form validations.

File

./ife.settings.inc, line 134
Admin settings pages.

Code

function ife_settings_form_validate($form, &$form_state) {
  $values = $form_state['values'];
  $new_form_id = trim($values['form_ids']['new_form_id']['form_id']);

  // Check if form_id already exists.
  if ($new_form_id && ife_form_id_load($new_form_id)) {
    form_set_error('form_ids][new_form_id][form_id', t('The form %form_id has already been added.', array(
      '%form_id' => $new_form_id,
    )));
  }

  // Check if the form_id is valid.
  if (!preg_match('/^[a-z0-9_*]*$/', $new_form_id)) {
    form_set_error('form_ids][new_form_id][form_id', t('The form_id %form_id is invalid.', array(
      '%form_id' => $new_form_id,
    )));
  }
}