views:

23

answers:

1

I have a view where I am exposing a filter which is the Price of a product. I want the user to be able to choose the price(filter based on price), So I exposed the filter, then unlocked the operator and all of them are unlocked(operators). Is there a way where I can unlock only a few operators such as "Is less than", "In Between", "Is Greater than". I don't want the user to be selecting "Is Empty", "Is not empty".

+2  A: 

This is pretty easy with a custom module and hook_form_alter():

function mymodule_form_alter(&$form, &$form_state, $form_id) {

  // Change test to the name of your view
  if ($form_id == 'views_exposed_form' && $form_state['view']->name == 'test') {

    // Change field_test_value_op to the identifier you specified
    unset($form['field_test_value_op']['#options']['empty']);
    unset($form['field_test_value_op']['#options']['not empty']);
  }
}
Mark Trapp
Thanks a lot for the solution. I was assuming that there was some configuration setting which I was missing.
charan

related questions