public function YieldToArgumentTrait::buildExposeForm in Lightning Core 8        
                          
                  
                        Same name and namespace in other branches
- 8.5 src/YieldToArgumentTrait.php \Drupal\lightning_core\YieldToArgumentTrait::buildExposeForm()
- 8.2 src/YieldToArgumentTrait.php \Drupal\lightning_core\YieldToArgumentTrait::buildExposeForm()
- 8.3 src/YieldToArgumentTrait.php \Drupal\lightning_core\YieldToArgumentTrait::buildExposeForm()
- 8.4 src/YieldToArgumentTrait.php \Drupal\lightning_core\YieldToArgumentTrait::buildExposeForm()
File
 
   - src/YieldToArgumentTrait.php, line 37
Class
  
  - YieldToArgumentTrait 
- Allows exposed an Views filter to disappear if an argument is present.
Namespace
  Drupal\lightning_core
Code
public function buildExposeForm(&$form, FormStateInterface $form_state) {
  parent::buildExposeForm($form, $form_state);
  $form['expose']['argument'] = [
    '#type' => 'select',
    '#title' => $this
      ->t('Yield to argument'),
    '#options' => [],
    '#empty_option' => $this
      ->t('- None -'),
    '#default_value' => $this->options['expose']['argument'],
    '#description' => $this
      ->t('If this argument has a non-null value (given or default), this filter will not be exposed to the user.'),
  ];
  
  foreach ($this->displayHandler
    ->getHandlers('argument') as $id => $argument) {
    $form['expose']['argument']['#options'][$id] = $argument
      ->adminLabel();
    $form['expose']['argument']['#access'] = TRUE;
  }
}