function system_add_date_format_type_form_validate

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 modules/system/system.admin.inc
Add new date type.

File

modules/system/system.admin.inc, line 2180

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.'));
        }
    }
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.