function date_field_settings_form in Date 5.2
Same name and namespace in other branches
- 8 date.field.inc \date_field_settings_form()
- 5 date_admin.inc \date_field_settings_form()
- 6.2 date/date_admin.inc \date_field_settings_form()
- 6 date/date_admin.inc \date_field_settings_form()
- 7.3 date.field.inc \date_field_settings_form()
- 7 date.field.inc \date_field_settings_form()
- 7.2 date.field.inc \date_field_settings_form()
1 call to date_field_settings_form()
- _date_field_settings in date/
date_admin.inc - Implementation of hook_field_settings().
File
- date/
date_admin.inc, line 320 - 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) {
$form = array(
'#validate' => array(
'date_field_settings_validate' => array(),
),
);
$tz_handling = $field['tz_handling'] ? $field['tz_handling'] : (date_has_time($field['granularity']) ? 'site' : 'none');
// Override the normal multiple checkbox when using date repeat.
$options = array(
0 => t('Never'),
1 => t('Unlimited'),
);
$description = t('Choose an option for handling multiple values. Unlimited will allow the user to manually create unlimited multiple dates one date at a time.');
if (module_exists('date_repeat')) {
$options += array(
99 => t('Repeating'),
);
$description .= t(' Repeating dates will allow the user to select when and how often the date will repeat.');
}
$description .= date_data_loss_warning('Multiple');
$form['repeat'] = array(
'#type' => 'value',
'#value' => $field['repeat'],
);
$form['multiple'] = array(
'#type' => 'radios',
'#title' => t('Multiple'),
'#options' => $options,
'#default_value' => !empty($field['repeat']) ? 99 : $field['multiple'],
'#description' => $description,
);
$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.");
$description .= date_data_loss_warning('To date');
$form['input']['todate'] = array(
'#type' => 'radios',
'#title' => t('To Date'),
'#options' => array(
'' => t('Never'),
'optional' => t('Optional'),
'required' => t('Required'),
),
'#description' => $description,
'#default_value' => $field['todate'] ? $field['todate'] : '',
);
// Make sure granularity is in the right format and has no empty values.
if (!empty($field['granularity']) && is_array($field['granularity'])) {
$granularity = array_filter($field['granularity']);
}
else {
$granularity = array(
'year',
'month',
'day',
'hour',
'minute',
);
}
$form['input']['granularity'] = array(
'#type' => 'select',
'#title' => t('Granularity'),
'#default_value' => $granularity,
'#options' => date_granularity_names(),
'#multiple' => TRUE,
'#description' => t('Set the date elements to be stored (at least a year is required).'),
);
$form['output']['simple'] = date_formatter_setup_form($field, 0);
$form['output']['simple']['#title'] = t('Default Display');
$form['output']['advanced'] = array(
'#type' => 'fieldset',
'#title' => t('Additional Display Settings'),
'#collapsible' => TRUE,
'#collapsed' => TRUE,
'#description' => t('Define alternate formatting for the date display. Options other than the default are made available to views and themes. Possible formats are default, long, medium, and short.'),
);
for ($i = 1; $i <= 3; $i++) {
$form['output']['advanced'][$i] = date_formatter_setup_form($field, $i);
}
$description = t('Select the timezone handling method to be used for this date field.');
$description .= date_data_loss_warning('Time zone handling');
$form['tz_handling'] = array(
'#type' => 'select',
'#title' => t('Time zone handling'),
'#default_value' => $tz_handling,
'#options' => date_timezone_handling_options(),
'#description' => $description,
);
// 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($field['tz_handling']),
);
if (module_exists('date_repeat')) {
$form['repeat_collapsed'] = array(
'#type' => 'select',
'#default_value' => !empty($field['repeat_collapsed']) ? intval($field['repeat_collapsed']) : 0,
'#options' => array(
0 => t('Expanded'),
1 => t('Collapsed'),
),
'#title' => t('Repeat display'),
'#description' => t('If set to use repeating dates, should the repeat options form start out expanded or collapsed? Set to \'Collapsed\' to make those options less obtrusive.'),
);
}
$form['#suffix'] = t('<div class="form-item"><div class="description">* The custom format, if provided, will override the selected display or input options. Define a php date format string like \'m-d-Y H:i\' (see !link for more details).</div></div>', array(
'!link' => l('http://php.net/date', 'http://php.net/date'),
));
return $form;
}