I am trying to apply an exposed filter programmatically.
If filter 'a' is set to 'apple' I want to set filter 'b' to 'green'.
Using this code updates the filter. If a user sets the drop-down filter 'a' to 'apple' and clicks apply, then the drop-down filter 'b' is updated to 'green'; but the filter isn't applied. The results still show what the user had set filter 'b' to, instead of updating the results to show if filter 'b' was set to 'green'.
function my_module_views_pre_view(ViewExecutable $view, string $display_id, array $args) {
if (($view->id() === 'my_view')) {
$exposedInput = $view->getExposedInput();
if ($exposedInput['a'] = 'apple') {
$exposedInput['b'] = 'green';
}
$view->setExposedInput($exposedInput);
}
}
How can I update the results, not just set the drop-down filter value?