function EntityReference::validateExposed

Overrides HandlerBase::validateExposed

File

core/modules/views/src/Plugin/views/filter/EntityReference.php, line 637

Class

EntityReference
Filters a view by entity references.

Namespace

Drupal\views\Plugin\views\filter

Code

public function validateExposed(&$form, FormStateInterface $form_state) : void {
    if (empty($this->options['exposed'])) {
        return;
    }
    $identifier = $this->options['expose']['identifier'];
    // Set the validated exposed input from the select list when not the all
    // value option.
    if ($this->options['widget'] == static::WIDGET_SELECT) {
        if ($form_state->getValue($identifier) != static::ALL_VALUE) {
            $this->validatedExposedInput = (array) $form_state->getValue($identifier);
        }
        return;
    }
    if (empty($identifier)) {
        return;
    }
    $values = $form_state->getValue($identifier);
    if (!is_array($values)) {
        return;
    }
    foreach ($values as $value) {
        $this->validatedExposedInput[] = $value['target_id'];
    }
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.