Drupal Answers Asked on November 5, 2021
Is there a way to limit the operators for views-filtering for users. I want them to only have “starts-with”, “contains” and “same”. But not the rest. Do I have to form_alter with a custom module? Or is there some intern way to achieve that?
I don't think there is an option to sort the exposed operators.
You can do it with a custom module using hook_form_alter().
Example:
function module_name_form_alter(&$form, &$form_state, $form_id) {
if ($form_id == 'views_exposed_form' && $form_state['view']->name == 'view_name') {
unset($form['field_name_filter_op']['#options']['empty']);
unset($form['field_name_filter_op']['#options']['not empty']);
}
}
You can find the form details using "dpm()" from devel module.
Answered by NeoHQ on November 5, 2021
Get help from others!
Recent Answers
Recent Questions
© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP