You are here

function date_tools_wizard_form_validate in Date 6.2

Same name and namespace in other branches
  1. 8 date_tools/date_tools.wizard.inc \date_tools_wizard_form_validate()
  2. 7.3 date_tools/date_tools.wizard.inc \date_tools_wizard_form_validate()
  3. 7 date_tools/date_tools.wizard.inc \date_tools_wizard_form_validate()
  4. 7.2 date_tools/date_tools.wizard.inc \date_tools_wizard_form_validate()

File

date_tools/date_tools.wizard.inc, line 112
Date Wizard code.

Code

function date_tools_wizard_form_validate(&$form, &$form_state) {
  $type_name = $form_state['values']['type_name'];
  $field_name = 'field_' . $form_state['values']['field_name'];
  if (db_result(db_query("SELECT type FROM {node_type} WHERE type='%s'", $type_name))) {
    drupal_set_message(t('This content type name already exists, adding new field to existing content type.'));
  }
  if (!preg_match('!^[a-z0-9_]+$!', $type_name)) {
    form_set_error('type_name', t('The machine-readable name must contain only lowercase letters, numbers, and underscores.'));
  }
  if (db_result(db_query("SELECT field_name FROM {content_node_field_instance} WHERE field_name='%s' AND type_name='%s'", $field_name, $type_name))) {
    form_set_error('field_name', t('This field name already exists.'));
  }
  if (!date_has_time($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.'));
  }
}