function system_date_formats_form_validate

Validate date format string submission.

1 string reference to 'system_date_formats_form_validate'
system_configure_date_formats_form in drupal/core/modules/system/system.admin.inc
Allow users to add additional date formats.

File

drupal/core/modules/system/system.admin.inc, line 2688
Admin page callbacks for the system module.

Code

function system_date_formats_form_validate($form, &$form_state) {
  $formats = system_get_date_formats();
  $format = trim($form_state['values']['date_format_pattern']);

  // The machine name field should already check to see if the requested
  // machine name is available. Regardless of machine_name or human readable
  // name, check to see if the provided pattern exists.
  if (!empty($formats) && in_array($format, array_values($formats)) && (!isset($form_state['values']['date_format_id']) || $form_state['values']['date_format_id'] != $formats[$format]['date_format_id'])) {
    form_set_error('date_format', t('This format already exists. Enter a unique format string.'));
  }
}