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".
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试):
问题:
回答1:
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']);
}
}