Community

Removing Field from Views Exposed Form Filter

I have a view for my taxonomy terms. So all taxonomy terms end up overridden by this view. This view has an exposed form with filters. Everything works great, except for one single page/term, I want to remove one of the filter fields (color). On this one page, having an exposed filter for color makes no sense.

Now I don't know of any way to do this on the backend UI.

In a hook_form_alter function I have tried this...

<?php
   
unset($form['#info']['filter-field_product_details_color_value']);
    unset(
$form['field_product_details_color_value']);
?>

This removes it, but then I get an error...

Notice: Undefined index: field_product_details_color_value in views_handler_filter->accept_exposed_input() (line 547 of /home/websites/sites/client/public_html/sites/all/modules/views/handlers/views_handler_filter.inc).

So I'm at a loss. Is there any way at all I can programmatically remove this single field in a proper way that makes Drupal, Views and me happy? Any help would be great.

Comments

How about instead of   

How about instead of

    unset($form['field_product_details_color_value']);

trying
    $form['field_product_details_color_value']['#access'] = FALSE;

Ah yeah. Good thought. It

Ah yeah. Good thought. It leaves the list element. The options are just empty. So I used some jquery code to just remove all the list elements that contain empty .views-widgets divs.

Thanks!

nobody click here