You are here

function system_add_date_formats_form_validate in Drupal 7

Validate new date format string submission.

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

File

modules/system/system.admin.inc, line 2949
Admin page callbacks for the system module.

Code

function system_add_date_formats_form_validate($form, &$form_state) {
  $formats = system_get_date_formats('custom');
  $format = trim($form_state['values']['date_format']);
  if (!empty($formats) && in_array($format, array_keys($formats)) && (!isset($form_state['values']['dfid']) || $form_state['values']['dfid'] != $formats[$format]['dfid'])) {
    form_set_error('date_format', t('This format already exists. Enter a unique format string.'));
  }
}