Programatically change exposed filter value based on another exposed filter I have 2 exposed filters in my Drupal 8 view - both are select dropdowns. I want the value of the 2nd filter to change based on selection of first filter
Here are the filters
$filters = $view-&gt;display_handler-&gt;getOption('filters');

$filters['country'] and $filters['states'].

Problem is that I always get an empty value when I try to access country filter in my views_pre_view hook.

dpm($filters['country']['value']) always prints empty.

How do I solve this please?
You don't have access to your filter options inside hook_views_pre_view.  

$filters = $view-&gt;display_handler-&gt;getOption('filters');


give only informations about the filter something like:

 "field_country_target_id" =&gt; array:20 [▼
    "id" =&gt; "field_country_target_id"
    "table" =&gt; "node__field_country"
    "field" =&gt; "field_country_target_id"
    "relationship" =&gt; "none"
    "group_type" =&gt; "group"
    "admin_label" =&gt; ""
    "operator" =&gt; "or"
    "value" =&gt; []
    "group" =&gt; 1
    "exposed" =&gt; true
    "expose" =&gt; array:13 [▶]
    "is_grouped" =&gt; false
    "group_info" =&gt; array:10 [▶]
    "reduce_duplicates" =&gt; false
    "type" =&gt; "select"
    "limit" =&gt; true
    "vid" =&gt; "countries"
    "hierarchy" =&gt; false
    "error_message" =&gt; true
    "plugin_id" =&gt; "taxonomy_index_tid"
  ]


To get the selected filter values with:

$filters_selected = $view-&gt;getExposedInput(); 


Even you get the filter options you can't alter it because exposed filters are form inputs.
So i thing the best way to achieve this is by using hook_form_FORM_ID_alter like the following.

/**
 * Implements hook_form_FORM_ID_alter().
 */
function MY_MODUOLE_form_views_exposed_form_alter(&amp;$form, FormStateInterface $form_state, $form_id) {
  // Here is options of your country filter
  // Note that they key is FIELD_NAME_target_id
  // Change the FIELD_NAME with you field name
  $countries = $form['field_country_target_id']['#options'];
  // Get the city options the same way .
  /**
   * TODO: To alter options array change $form['field_country_target_id']['#options'] not the $countries
   */
}