function system_add_date_format_type_form_validate

7.x system.admin.inc system_add_date_format_type_form_validate($form, &$form_state)

Validate system_add_date_format_type form submissions.

1 string reference to 'system_add_date_format_type_form_validate'
system_add_date_format_type_form in drupal-7.x/modules/system/system.admin.inc
Add new date type.

File

drupal-7.x/modules/system/system.admin.inc, line 2157
Admin page callbacks for the system module.

Code

function system_add_date_format_type_form_validate($form, &$form_state) {
  if (!empty($form_state['values']['machine_name']) && !empty($form_state['values']['date_type'])) {
    if (!preg_match("/^[a-zA-Z0-9_]+$/", trim($form_state['values']['machine_name']))) {
      form_set_error('machine_name', t('The date type must contain only alphanumeric characters and underscores.'));
    }
    $types = system_get_date_types();
    if (in_array(trim($form_state['values']['machine_name']), array_keys($types))) {
      form_set_error('machine_name', t('This date type already exists. Enter a unique type.'));
    }
  }
}