function date_tools_wizard_form_validate in Date 8
Same name and namespace in other branches
- 6.2 date_tools/date_tools.wizard.inc \date_tools_wizard_form_validate()
- 7.3 date_tools/date_tools.wizard.inc \date_tools_wizard_form_validate()
- 7 date_tools/date_tools.wizard.inc \date_tools_wizard_form_validate()
- 7.2 date_tools/date_tools.wizard.inc \date_tools_wizard_form_validate()
@todo.
File
- date_tools/
date_tools.wizard.inc, line 126 - The Date Wizard code.
Code
function date_tools_wizard_form_validate(&$form, &$form_state) {
$bundle = $form_state['values']['bundle'];
$field_name = 'field_' . $form_state['values']['field_name'];
$existing_type = db_query("SELECT type FROM {node_type} WHERE type=:bundle", array(
':bundle' => $bundle,
))
->fetchField();
$existing_instance = db_query("SELECT field_name FROM {field_config_instance} WHERE field_name=:field_name AND bundle=:bundle AND entity_type=:entity_type", array(
':field_name' => $field_name,
':bundle' => $bundle,
':entity_type' => 'node',
))
->fetchField();
if ($existing_type) {
drupal_set_message(t('This content type name already exists, adding new field to existing content type.'));
}
if (!preg_match('!^[a-z0-9_]+$!', $bundle)) {
form_set_error('bundle', t('The machine-readable name must contain only lowercase letters, numbers, and underscores.'));
}
if (!empty($form_state['values']['calendar']) && !empty($form_state['values']['blocks']) && strlen($bundle) > 12) {
form_set_error('bundle', t('The content type name must be no more than 12 characters long when using it to create a calendar and blocks.'));
}
if ($existing_instance) {
form_set_error('field_name', t('This field name already exists.'));
}
if (strlen($field_name) > 32) {
form_set_error('field_name', t('The field name must be no more than 26 characters long.'));
}
if (!DateGranularity::hasTime($form_state['values']['granularity']) && $form_state['values']['tz_handling'] != 'none') {
form_set_error('tz_handling', t('Timezone handling must be none for granularity without time.'));
}
}