function office_hours_handler_filter_day::value_form in Office Hours 7
Same name and namespace in other branches
- 6.2 includes/office_hours_handler_filter_day.inc \office_hours_handler_filter_day::value_form()
- 6 includes/office_hours_handler_filter_day.inc \office_hours_handler_filter_day::value_form()
Provides the form.
File
- includes/
office_hours_handler_filter_day.inc, line 46 - Implements Views integration: day filter.
Class
- office_hours_handler_filter_day
- @file Implements Views integration: day filter.
Code
function value_form(&$form, &$form_state) {
$this
->get_value_options();
$options = $this->value_options;
$default_value = (array) $this->value;
if (!empty($form_state['exposed'])) {
$identifier = $this->options['expose']['identifier'];
if (!empty($this->options['expose']['reduce'])) {
$options = $this
->reduce_value_options();
if (empty($this->options['expose']['single']) && !empty($this->options['expose']['optional'])) {
$default_value = array();
}
}
if (!empty($this->options['expose']['single'])) {
if (!empty($this->options['expose']['optional']) && (empty($default_value) || !empty($this->options['expose']['reduce']))) {
$default_value = 'All';
}
elseif (empty($default_value)) {
$keys = array_keys($options);
$default_value = array_shift($keys);
}
else {
$copy = $default_value;
$default_value = array_shift($copy);
}
}
}
$form['value'] = array(
'#type' => $this->value_form_type,
'#title' => check_plain($this->value_title),
'#options' => $options,
'#default_value' => $default_value,
// These are only valid for 'select' type, but do no harm to checkboxes.
'#multiple' => TRUE,
'#size' => count($options) > 8 ? 8 : count($options),
);
if (!empty($form_state['exposed']) && !isset($form_state['input'][$identifier])) {
$form_state['input'][$identifier] = $default_value;
}
}