You are here

function date_tools_change_type_form in Date 7.2

Same name and namespace in other branches
  1. 8 date_tools/date_tools.change_type.inc \date_tools_change_type_form()
  2. 6.2 date_tools/date_tools.change_type.inc \date_tools_change_type_form()
  3. 7.3 date_tools/date_tools.change_type.inc \date_tools_change_type_form()
  4. 7 date_tools/date_tools.change_type.inc \date_tools_change_type_form()

Form constructor for the date type change form.

@todo This is broken, still needs to be adjusted for the D6->D7 changes.

See also

date_tools_change_type_form_validate()

date_tools_change_type_form_submit()

File

date_tools/date_tools.change_type.inc, line 16
A form to change the type of date used in date fields.

Code

function date_tools_change_type_form() {
  $form = array();
  drupal_set_message(t('This operation does not yet work for the Drupal 7 version.'), 'error');
  return $form;
  $fields = content_fields();
  $date_options = array();
  $type_options = array();
  $labels = array();
  foreach (date_field_info() as $type => $info) {
    $type_options[$type] = $info['label'] . ': ' . $info['description'];
    $labels[$type] = $info['label'];
  }

  // Get the available date fields.
  foreach ($fields as $field_name => $field) {
    if ($field['type'] == 'date' || $field['type'] == 'datestamp' || $field['type'] == 'datetime') {
      $date_options[$labels[$field['type']]][$field_name] = t('Field @label (@field_name)', array(
        '@label' => $field['widget']['label'],
        '@field_name' => $field_name,
        '@type' => $labels[$field['type']],
      ));
    }
  }
  if (count($date_options) < 1) {
    drupal_set_message(t('There are no date fields in this database.'));
    return $form;
  }
  $form['date_field'] = array(
    '#type' => 'select',
    '#options' => $date_options,
    '#title' => t('Date field'),
    '#default_value' => '',
    '#description' => t('The date field which whose type should be changed.'),
  );
  $form['type'] = array(
    '#type' => 'radios',
    '#options' => $type_options,
    '#default_value' => '',
    '#required' => TRUE,
    '#description' => t('The type of date to change the field to.'),
    '#prefix' => '<strong>' . t('New type:') . '</strong>',
  );
  $form['submit'] = array(
    '#type' => 'submit',
    '#value' => t('Change'),
  );
  return $form;
}