/ 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
/** * 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. } }
Comments
Subscribe to comments
You need to login to post a comment.

where does this snippet go?
This is the way I ended up solving this problem:
I put this snippet into my hookformalter() function
// Then here is the function that returns the options that came out of the drupal table
function fieldnameoptionvalues() { // contentfields function retrieves the possible values out of the drupal database table $field = contentfields('fieldfieldname',NULL); $options = explode(chr(10), $field['allowedvalues']);
}
/////////////////Here is another possible example of this function if you have key/ value pairs specified in your CCK type delinted with pipes.
function fieldname2optionvalues() {
}