Form constructor for the date localization configuration form.
$langcode: The code for the current language.
system_date_format_localize_form_submit()
function system_date_format_localize_form($form, &$form_state, $langcode) {
// Display the current language name.
$form['language'] = array(
'#type' => 'item',
'#title' => t('Language'),
'#markup' => language_load($langcode)->name,
'#weight' => -10,
);
$form['langcode'] = array(
'#type' => 'value',
'#value' => $langcode,
);
// Get list of available formats.
$formats = system_get_date_formats();
$choices = array();
foreach ($formats as $date_format_id => $format_info) {
// Ignore values that are localized.
if (empty($format_info['locales'])) {
$choices[$date_format_id] = format_date(REQUEST_TIME, $date_format_id);
}
else {
unset($formats[$date_format_id]);
}
}
// Get configured formats for each language.
$locale_formats = system_date_format_locale($langcode);
if (!empty($locale_formats)) {
$formats += $locale_formats;
foreach ($locale_formats as $date_format_id => $format_info) {
$choices[$date_format_id] = format_date(REQUEST_TIME, $date_format_id);
}
}
// Display a form field for each format type.
foreach ($formats as $date_format_id => $format_info) {
// Show date format select list.
$form['date_formats']['date_format_' . $date_format_id] = array(
'#type' => 'select',
'#title' => check_plain($format_info['name']),
'#attributes' => array(
'class' => array(
'date-format',
),
),
'#default_value' => isset($choices[$date_format_id]) ? $date_format_id : 'custom',
'#options' => $choices,
);
}
$form['actions'] = array(
'#type' => 'actions',
);
$form['actions']['submit'] = array(
'#type' => 'submit',
'#value' => t('Save configuration'),
);
return $form;
}