system_add_date_format_type_form

7 system.admin.inc system_add_date_format_type_form($form, &$form_state)
8 system.admin.inc system_add_date_format_type_form($form, &$form_state)

Add new date type.

Related topics

1 string reference to 'system_add_date_format_type_form'

File

modules/system/system.admin.inc, line 2092
Admin page callbacks for the system module.

Code

function system_add_date_format_type_form($form, &$form_state) {
  $form['date_type'] = array(
    '#title' => t('Date type'), 
    '#type' => 'textfield', 
    '#required' => TRUE,
  );
  $form['machine_name'] = array(
    '#type' => 'machine_name', 
    '#machine_name' => array(
      'exists' => 'system_get_date_types', 
      'source' => array('date_type'),
    ),
  );

  // Get list of all available date formats.
  $formats = array();
  drupal_static_reset('system_get_date_formats');
  $date_formats = system_get_date_formats(); // Call this to rebuild the list, and to have default list.
  foreach ($date_formats as $type => $format_info) {
    $formats = array_merge($formats, $format_info);
  }
  $custom_formats = system_get_date_formats('custom');
  if (!empty($custom_formats)) {
    $formats = array_merge($formats, $custom_formats);
  }
  $choices = array();
  foreach ($formats as $f => $format) {
    $choices[$f] = format_date(REQUEST_TIME, 'custom', $f);
  }
  // Show date format select list.
  $form['date_format'] = array(
    '#type' => 'select', 
    '#title' => t('Date format'), 
    '#attributes' => array('class' => array('date-format')), 
    '#options' => $choices, 
    '#required' => TRUE,
  );

  $form['actions'] = array('#type' => 'actions');
  $form['actions']['submit'] = array(
    '#type' => 'submit', 
    '#value' => t('Add date type'),
  );

  $form['#validate'][] = 'system_add_date_format_type_form_validate';
  $form['#submit'][] = 'system_add_date_format_type_form_submit';

  return $form;
}
Login or register to post comments