Views > Exposed Filter > How to disable output of options that aren't attached/used by a node I have a exposed filter setup to filter content within a view.

The view is displaying a list of house designs. These designs need to be able to be filtered by number of beds, bathrooms etc.

"House Design" content type/node has a field (List (integer)) for bedrooms:

http://theexhale.com/screenshot_1.png

The allowed values for this field are 1,2,3,4,5 (bedrooms)

http://theexhale.com/screenshot_2.png

The issue I'm having is that the exposed filter is outputting all of these fields for sorting the view even though currently only values "2" and "4" are being used by the "House Design" content type.

http://theexhale.com/screenshot_5.png

QUESTION: Can the exposed filter be smart enough to check to see if values of a field/taxonomy vocab are actually being used by the displayed content type/node and then dynamically only display those values in the filter?

I want to do this to remove/lesson the possibility of no results when a user uses the filter.

Thank you :)
The concept's the same in Drupal 8 but the access of properties and handling is a little different from what's done on D7. Here's a working example of 3 exposed filters dependent on each other to allow only values available based on prior selections. 

Tips: 
- View is built with page that has exposed form in block checked to yes.
- Enable master display, make sure filter identify of exposed filter is same
- Use BEF (better exposed filters) for menu select and autosubmit
- See code comments

This is for D8:

/**


* @file
 * Provides functionality for handling exposed filters
 */

use Drupal\Core\Form\FormStateInterface;
use Drupal\views\ViewExecutable;
use Drupal\views\Plugin\views\query\QueryPluginBase;
use Drupal\views\Plugin\views\query\Sql;
use Drupal\views\ResultRow;
use Drupal\Core\Field\Plugin\Field\FieldType\EntityReferenceItem;
use Drupal\views\Entity\View;
use Drupal\Core\Form\FormState;
use Drupal\Core\Form;
use Drupal\taxonomy\Entity\Term;
use Drupal\Core\Entity;

/**
   * Implements hook_views_exposed_form_alter().
   *
   * alters exposed filter for equipment selector to limit filtered results in a new view
   */
function ahern_equipment_selector_form_views_exposed_form_alter(&amp;$form,  &amp;$form_state){
    if ($form['#id'] == 'views-exposed-form-ahern-exposed-filters-page-1') {
        // Get whatever values selected by user in all menus
        $input = &amp;$form_state-&gt;getUserInput();

        // Form fields have given/arbitrary name from Filter identifier in Exposed filter settings
        $selected_what_moving = $input['moving'];
        $selected_where_working = $input['where'];
        $selected_height = $input['height'];

        // Again, form fields have given/arbitrary name from Filter identifier in Exposed filter settings
        // NOTE: make sure also match Filter identifier in Master display
        // Also keep in mind that any view duplicated/cloned from main view should be disabled as 
        // it can/will affect results
        $form['moving']['#options'] = _get_associative_array_from_view(
         'ahern_exposed_filters', // viewi id
          'default', // view dsplay id
          $selected_what_moving,
          'moving_chosen'
        );

        $form['where']['#options'] = _get_associative_array_from_view(
         'ahern_exposed_filters', // viewi id
          'default', // view dsplay id        
          $selected_where_working,
          'where_chosen'
        );

        $form['height']['#options'] = _get_associative_array_from_view(
         'ahern_exposed_filters', // viewi id
          'default', // view dsplay id
          $selected_height,
          'height_chosen'
        );
    }
}

function _get_associative_array_from_view($viewID, $viewDisplayID, $contextualFilter, $menu_chosen){
//ksm($contextualFilter,'context filter');

  $associativeArray = array();
  $associativeArray['All'] = t('- Any -');
  $viewResults = views_get_view_result($viewID, $viewDisplayID, $contextualFilter);

  foreach($viewResults as $viewRow) {

    switch ($menu_chosen) {
    // views_get_view_result returns rows with original field name so don't use filter identifier name to acceess, use field name
        case 'moving_chosen':
            //ksm($menu_chosen, 'target menu to filter to');
            $term_name = $viewRow-&gt;_relationship_entities['field_what_are_you_moving']-&gt;getName();
            $term_id = $viewRow-&gt;_relationship_entities['field_what_are_you_moving']-&gt;id();
            if (!in_array($term_name,$associativeArray)) {
                $associativeArray[] = $associativeArray[$term_id] = $term_name;
            }
            break;

        case 'where_chosen':
            $term_name = $viewRow-&gt;_relationship_entities['field_attr_where_are_you_working']-&gt;getName();
             $term_id = $viewRow-&gt;_relationship_entities['field_attr_where_are_you_working']-&gt;id();
             if (!in_array($term_name,$associativeArray)) {
                $associativeArray[] = $associativeArray[$term_id] = $term_name;
            }
            break;

        case 'height_chosen':
            //ksm($menu_chosen, 'target menu to filter to');
            $term_name = $viewRow-&gt;_relationship_entities['field_what_is_the_working_height']-&gt;getName();
            $term_id = $viewRow-&gt;_relationship_entities['field_what_is_the_working_height']-&gt;id();
            if (!in_array($term_name,$associativeArray)) {
                $associativeArray[] = $associativeArray[$term_id] = $term_name;
            }
            asort($associativeArray);
            break;

        default:
            break;
    }

  }

    $associativeArray = array_unique($associativeArray);
    return $associativeArray;
}