protected function availability_calendar_handler_filter_availability::value_form_date_field in Availability Calendars 7.5
Returns a date form field definition for the given operand
Parameters
string[] $operators: The names of the possible operators for this operand in the given context: at, from_to, from_to1, from_duration
string $operand: The name of the operand: from, to, to1, duration
string $dependency_source: The name of the dependency source
Return value
array A form field definition.
1 call to availability_calendar_handler_filter_availability::value_form_date_field()
- availability_calendar_handler_filter_availability::value_form in views/
availability_calendar_handler_filter_availability.inc - Add validation and date popup(s) to the value form.
File
- views/
availability_calendar_handler_filter_availability.inc, line 188
Class
- availability_calendar_handler_filter_availability
- Views handler to filter on availability.
Code
protected function value_form_date_field($operators, $operand, $dependency_source) {
$operator = in_array($this->operator, $operators) ? $this->operator : reset($operators);
$variable_name = "availability_calendar_views_op_{$operator}_{$operand}";
$element = array(
'#type' => 'textfield',
'#title' => availability_calendar_get_customizable_text($variable_name),
'#size' => 12,
'#default_value' => $this->value[$operand],
);
if (module_exists('date_popup')) {
$this
->change_element_into_date_popup($element);
}
else {
$date_example = new DateTime();
if ($operand === 'to') {
$date_example
->modify('+6');
}
else {
if ($operand === 'to1') {
$date_example
->modify('+7');
}
}
$date_example = availability_calendar_format_entry_date($date_example);
$element['#description'] = t('E.g., @date', array(
'@date' => $date_example,
));
}
if ($dependency_source !== NULL) {
$element['#dependency'] = array(
$dependency_source => $operators,
);
}
return $element;
}