Hello.
I have a question and don't know exactly where to ask it. I've been reading some documentation but everything looks a little scattered.
I have a view with a Content Taxonomy field as a filter. It displays a nice drowpdown (force single is selected) and all works fine.
I like how a dropdown is displayed but sometimes I may need to allow selecting multiple terms.
What I did was to uncheck the force single which rendered a multiselect list and then I rendered my own dropdown widget on hook_preprocess_views_exposed_form.
When I selected items it did not filter anything as because in the views configuration it is a non force single, it seems to expect an array of parameters nevertheless.
Is there any way to have a dropdown and when some param is passed it changes the internal filtering to not force single? I've been digging around and came across hook_views_pre_build but can't find where the filter options and values are set.
Right now I'm already using hook_views_pre_build do remove columns when a filter is set (works beautifully).
I will attach my code just as reference. Any comments welcome.
<?php
//this is a theme function
//gets my nice dropdown back
function referup_preprocess_views_exposed_form(&$vars, $hook) {
switch($vars['form']['#id']){
case 'views-exposed-form-empleo-page-1':
case 'views-exposed-form-empleo-page-2':
case 'views-exposed-form-empleo-page-3':
case 'views-exposed-form-empleo-page-4':
case 'views-exposed-form-empleo-page-5':
case 'views-exposed-form-empleo-page-6':
unset($vars['form']['field_oferta_industria_value']['#processed']);
unset($vars['form']['field_oferta_industria_value']['#defaults_loaded']);
unset($vars['form']['field_oferta_industria_value']['#printed']);
unset($vars['form']['field_oferta_industria_value']['#options']);
$vars['form']['field_oferta_industria_value']['#multiple'] = false;
$vars['form']['field_oferta_industria_value']['#size'] = 1;
$widget = $vars['widgets']['filter-field_oferta_industria_value'];
//$widget->widget = drupal_render($vars['form']['field_oferta_industria_value']);
drupal_set_message(var_export($vars['form']['field_oferta_zona_value'],true),'info');
// wont filter because if i uncheck the force single option i will be expecting a parameter as an array
// /empleo?field_oferta_industria_value[]=41&field_oferta_industria_value[]=17&field_oferta_industria_value[]=7
?>
<?php
function valls_support_views_pre_build(&$view) {
//removes a column if the filter for that column is set
if($view->name=='empleo'){
if(isset($_GET['field_oferta_industria_value']) && $_GET['field_oferta_industria_value']!='All' && !is_array($_GET['field_oferta_industria_value']))){
// remove view hander properties for column
unset(
$view->display['default']->handler->options['fields']['field_oferta_industria_value'],
$view->display['default']->handler->options['style_options']['columns']['field_oferta_industria_value'],
$view->display['default']->handler->options['style_options']['info']['field_oferta_industria_value']
);
}
?>