function _date_field_settings_form in Date 7
Same name and namespace in other branches
- 8 date_admin.inc \_date_field_settings_form()
- 7.3 date_admin.inc \_date_field_settings_form()
- 7.2 date_admin.inc \_date_field_settings_form()
1 call to _date_field_settings_form()
File
- ./
date_admin.inc, line 388 - Date administration code. Moved to separate file since there is a lot of code here that is not needed often.
Code
function _date_field_settings_form($field, $instance, $has_data) {
$settings = $field['settings'];
$form = array(
'#element_validate' => array(
'date_field_settings_validate',
),
);
// Make sure granularity is in the right format and has no empty values.
if (!empty($settings['granularity']) && is_array($settings['granularity'])) {
$granularity = array_filter($settings['granularity']);
}
$tz_handling = $settings['tz_handling'];
// If adding a repeat, override the Content module's handling of the multiple values option.
if (module_exists('date_repeat') && date_is_repeat_field($field, $instance)) {
$form['repeat'] = array(
'#type' => 'hidden',
'#value' => 1,
);
}
else {
$form['repeat'] = array(
'#type' => 'hidden',
'#value' => 0,
);
}
$description = t("Display a matching second date field as a 'To date' . If marked 'Optional' field will be presented but not required. If marked 'Required' the 'To date' will be required if the 'From date' is required or filled in.");
$form['todate'] = array(
'#type' => 'select',
'#title' => t('To Date'),
'#options' => array(
'' => t('Never'),
'optional' => t('Optional'),
'required' => t('Required'),
),
'#description' => $description,
'#default_value' => $settings['todate'],
'#disabled' => $has_data,
);
$description = t('Set the date elements to be stored (at least a year is required).');
$form['granularity'] = array(
'#type' => 'select',
'#title' => t('Granularity'),
'#default_value' => $granularity,
'#options' => date_granularity_names(),
'#multiple' => TRUE,
'#description' => $description,
'#disabled' => $has_data,
);
$description = t('Select the timezone handling method to be used for this date field.');
$form['tz_handling'] = array(
'#type' => 'select',
'#title' => t('Time zone handling'),
'#default_value' => $tz_handling,
'#options' => date_timezone_handling_options(),
'#description' => $description,
'#disabled' => $has_data,
);
// Force this value to hidden because we don't want to allow it to be changed right now,
// but allow it to be a variable if needed.
$form['timezone_db'] = array(
'#type' => 'hidden',
'#value' => date_get_timezone_db($tz_handling),
);
return $form;
}