How would I go about creating a drop down containing certain values from a datatable field when exposing a filter in the views module? wwhhhh that was a mouthful!
How would I go about creating a drop down containing certain values from a datatable field when exposing a filter in the views module? wwhhhh that was a mouthful!
Comments
Comment #1
jvdurme commentedMmm, just what I'm looking for.
Subscribe.
Comment #2
jvdurme commentedI got this working using the hook hook_form_FORM_ID_alter():
The form id in my case is "views_exposed_form" and I found this by calling the Devel module function:
in a view theme template file and then looking for variables > view > exposed_data > form_id
Hope this helps anyone.
Comment #3
quinns commentedHi,
Thanks to jvdurme I have a select-list with options from a data table and it works well. However, I cannot figure out how to enable the "All" option. I keep getting the "An illegal choice has been detected" error.
When I had the exposed filter as the default (text field), I also could not figure out how to get an "all results" option. If I left the field empty I got no results at all.
Anyone have an idea of how to get the "all results" working?
Thanks!
Comment #4
quinns commentedOk, I have figured out how to allow "Any" searches.
In my case, I had an array of form elements called
$carrier_name.The trick was to use have the
#default_valueelement as follows:$form['carrier_name']['#default_value'] = $form['carrier_name']['#options'][''];And, I set the first select option to have the label "Any" and no value to get the following markup:
<option selected="selected" value="">Any</option>I hope this helps someone.