You are here

function date_api_form_system_date_time_settings_alter in Date 6.2

Implementation of hook_form_alter().

Remove the 'date_formats' section from the 'admin/settings/date-time' page. This form section is now part of the form at 'admin/settings/date-time/formats'. We add the formats as values to the form to avoid errors on submission of the form when expected values are missing in system_date_time_settings_submit().

Add a form element to configure whether or not week numbers are ISO-8601 (default: FALSE == US/UK/AUS norm).

File

./date_api.module, line 2527
This module will make the date API available to other modules. Designed to provide a light but flexible assortment of functions and constants, with more functionality in additional files that are not loaded unless other modules specifically include them.

Code

function date_api_form_system_date_time_settings_alter(&$form, $form_state, $form_id = 'system_date_time_settings') {
  include_once drupal_get_path('module', 'date_api') . '/date_api.admin.inc';
  $formats_form = date_api_date_formats_form($form_state);
  $form['date_formats'] = $formats_form['date_formats'];
  foreach ($form['date_formats'] as $key => $value) {
    if (drupal_substr($key, 0, 1) != '#') {
      $form['date_formats'][$key]['#type'] = 'value';
    }
    else {
      unset($form['date_formats'][$key]);
    }
  }
  $form['locale']['date_api_use_iso8601'] = array(
    '#type' => 'checkbox',
    '#title' => t('Use ISO-8601 week numbers'),
    '#default_value' => variable_get('date_api_use_iso8601', FALSE),
    '#description' => t('IMPORTANT! If checked, First day of week MUST be set to Monday'),
  );
  $form['#validate'][] = 'date_api_form_system_settings_validate';
}