/ Published in: PHP
callback in a form alter to enforce an exposed filter to use only the options set in filter. Works for selectlists only.
Expand |
Embed | Plain Text
Copy this code and paste it in your HTML
/** * Form alter hook Callbacks and helpers */ function _mymodule_formalter_exported_filter(&$form) { $filter_id = 'workflow_node.sid'; //set this to the id of the filter. use print_r($form['view'][#value']->filter) to find the ID foreach($form['view']['#value']->filter as $filter) { if ($filter['field'] == $filter_id) { $only_these = $filter['value']; break; } } foreach ($form['filter0']['#options'] as $key => $option) { $options[$key] = $option; } } $form['filter0']['#options'] = $options; $form['filter0']['#default_value'] = 40; //or any other value. } }