function cck_select_other_handler_filter::value_form in CCK Select Other 7.2
Same name and namespace in other branches
- 7 views/cck_select_other_handler_filter.inc \cck_select_other_handler_filter::value_form()
Value form
Overrides views_handler_filter_in_operator::value_form
File
- views/
cck_select_other_handler_filter.inc, line 98
Class
- cck_select_other_handler_filter
- Extends Views in operator filter.
Code
function value_form(&$form, &$form_state) {
static $js;
parent::value_form($form, $form_state);
$default = array();
foreach ($this->value as $key => $value) {
// Populate default values.
if (in_array($value, $this->value_options)) {
$default[] = $value;
}
else {
$default[] = 'other';
}
}
$options = $form['value']['#options'];
$form['value'] = array(
'#type' => 'container',
'#tree' => TRUE,
'#parents' => array(
'options',
'value',
),
'select_other_list' => array(
// @note I am using checkboxes instead of select in the filter.
'#type' => 'checkboxes',
'#options' => $options,
'#default_value' => $default,
'#parents' => array(
'options',
'value',
'select_other_list',
),
),
);
if (!$js) {
drupal_add_js(drupal_get_path('module', 'cck_select_other') . '/cck_select_other.js');
$js = TRUE;
}
drupal_add_js(array(
'CCKSelectOther' => array(
array(
'field_id' => 'options-value',
),
),
), array(
'type' => 'setting',
));
}