function date_api_filter_handler::date_parts_form in Date 6.2
Same name and namespace in other branches
- 6 date_api.views.inc \date_api_filter_handler::date_parts_form()
A form element to select date part values.
Parameters
string $prefix: A prefix for the date values, 'value', 'min', or 'max'.
string $source: The operator for this element.
string $which: Which element to provide, 'all', 'value', or 'minmax'.
array $operator_values: An array of the allowed operators for this element.
array $limit: An array of date parts to limit this element to.
Return value
The form date part element for this instance.
1 call to date_api_filter_handler::date_parts_form()
- date_api_filter_handler::value_form in includes/
date_api_filter_handler.inc - Add the selectors to the value form using the date handler.
File
- includes/
date_api_filter_handler.inc, line 289 - Date Views filter handler.
Class
- date_api_filter_handler
- A flexible, configurable date filter.
Code
function date_parts_form($form_state, $prefix, $source, $which, $operator_values) {
require_once './' . drupal_get_path('module', 'date_api') . '/date_api_elements.inc';
switch ($prefix) {
case 'min':
$name = t('From date');
break;
case 'max':
$name = t('To date');
break;
default:
$name = '';
break;
}
$type = $this->options['form_type'];
if ($type == 'date_popup' && !module_exists('date_popup')) {
$type = 'date_text';
}
$format = $this->date_handler
->views_formats($this->options['granularity'], 'sql');
$granularity = array_keys($this->date_handler
->date_parts($this->options['granularity']));
// Don't set a default date in the UI, only in the exposed form.
$default_date = '';
if (!empty($form_state['exposed'])) {
$default_date = $this
->default_value($prefix);
}
$form[$prefix] = array(
'#type' => $type,
'#title' => check_plain($name),
'#size' => 20,
'#default_value' => empty($this->force_value) && !empty($this->value[$prefix]) ? $this->value[$prefix] : $default_date,
'#date_format' => date_limit_format($format, $granularity),
'#date_label_position' => 'within',
'#date_year_range' => $this->options['year_range'],
);
if ($which == 'all') {
$dependency = array(
'#process' => array(
$type . '_process',
'views_process_dependency',
),
'#dependency' => array(
$source => $operator_values,
),
);
$form[$prefix] += $dependency;
}
return $form;
}