function availability_calendars_handler_filter_availability::value_form in Availability Calendars 6.2
Add validation and date popup(s) to the value form.
File
Class
- availability_calendars_handler_filter_availability
- @class availability_calendars_handler_filter_availability Views handler to filter on availability.
Code
function value_form(&$form, &$form_state) {
parent::value_form($form, $form_state);
// Change labels.
if (isset($form['value']['min'])) {
$form['value']['min']['#title'] = t('Arrival date');
$form['value']['max']['#title'] = t('Departure date');
}
else {
$form['value']['#title'] = '';
}
// Remove the option, that date filter (our parent class) added, to define
// dates relatively.
if (empty($form_state['exposed']) && isset($form['value']['type'])) {
$form['value']['type']['#type'] = 'hidden';
$form['value']['type']['#default_value'] = 'date';
$form['value']['type']['#access'] = FALSE;
// Don't send to the client.
}
// Add validation.
$form['value']['#element_validate'][] = 'availability_calendars_handler_filter_availability_validate_value';
// Use date popups if that module is available.
if (module_exists('date_popup')) {
if (isset($form['value']['min'])) {
$form['value']['min'] = $this
->change_element_into_date_popup($form['value']['min']);
$form['value']['max'] = $this
->change_element_into_date_popup($form['value']['max']);
}
else {
if (isset($form['value']['#type']) && $form['value']['#type'] == 'textfield') {
$form['value'] = $this
->change_element_into_date_popup($form['value']);
}
}
}
}