function location_handler_filter_location_country::value_form in Location 6.3
Same name and namespace in other branches
- 7.5 handlers/location_handler_filter_location_country.inc \location_handler_filter_location_country::value_form()
- 7.3 handlers/location_handler_filter_location_country.inc \location_handler_filter_location_country::value_form()
- 7.4 handlers/location_handler_filter_location_country.inc \location_handler_filter_location_country::value_form()
Provide widgets for filtering by country.
File
- handlers/
location_handler_filter_location_country.inc, line 29
Class
- location_handler_filter_location_country
- Filter on country.
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']['use_operator']) || empty($this->options['expose']['operator'])) {
// exposed and locked.
$which = in_array($this->operator, $this
->operator_values(1)) ? 'value' : 'none';
}
else {
$source = 'edit-' . form_clean_id($this->options['expose']['operator']);
}
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';
}
else {
if (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' => 'select',
'#title' => t('Country'),
'#default_value' => $default_value,
'#options' => $options,
// Used by province autocompletion js.
'#attributes' => array(
'class' => 'location_auto_country',
),
'#multiple' => TRUE,
);
// Let location_autocomplete.js find the correct fields to attach.
$form['value']['#attributes']['class'] .= ' location_auto_join_' . $this->options['expose']['identifier'];
}