You are here

function editor_admin_format_form_validate in Editor 7

A copy of filter_admin_format_form_validate() which adds support for editors.

See also

editor_admin_format_form_submit()

filter_admin_format_form_validate()

1 string reference to 'editor_admin_format_form_validate'
editor_form_filter_admin_format_form_alter in includes/editor.admin.inc
Implements hook_form_FORM_ID_alter().

File

includes/editor.admin.inc, line 263
Replaces the core Filter module administration pages.

Code

function editor_admin_format_form_validate($form, &$form_state) {
  $format_format = trim($form_state['values']['format']);
  $format_name = trim($form_state['values']['name']);

  // Ensure that the values to be saved later are exactly the ones validated.
  form_set_value($form['format'], $format_format, $form_state);
  form_set_value($form['name'], $format_name, $form_state);
  $result = db_query("SELECT format FROM {filter_format} WHERE name = :name AND format <> :format", array(
    ':name' => $format_name,
    ':format' => $format_format,
  ))
    ->fetchField();
  if ($result) {
    form_set_error('name', t('Text format names must be unique. A format named %name already exists.', array(
      '%name' => $format_name,
    )));
  }
}