I have an existing view in which I want to change the available options in a view exposed filter. I can’t manipulate the form because the modifications are dependant on other views data, so I thought I could use a view hook:
function my_mdoule_views_pre_view($view, $display_id, $args) { // This doesn't work unfortunately if ($display_id === 'gallery_media_select_modal') { $filters = $view->display_handler->getOption('filters'); $filters['bundle']['operator'] = 'IN'; $filters['bundle']['value'] = ['image' => 'image']; $view->display_handler->overrideOption('filters', $filters); } }
This setting is basically the same that you can do in the UI, but like I said I need to do it dynamically.
I can see that this is in fact set correctly (and still set in later view hooks) but it’s never picked up by the code that is responsible for building the exposed select.
I’ve found many similar questions, but conclusively they’ve only been answered for Drupal 7, e.g. https://groups.drupal.org/node/82219