Skip to main content
Drupal API
User account menu
  • Log in

Breadcrumb

  1. Drupal Core 11.1.x
  2. EntityReference.php

function EntityReference::validate

Same name in this branch
  1. 11.1.x core/modules/views/src/Plugin/views/filter/EntityReference.php \Drupal\views\Plugin\views\filter\EntityReference::validate()

Overrides DisplayPluginBase::validate

File

core/modules/views/src/Plugin/views/display/EntityReference.php, line 219

Class

EntityReference
The plugin that handles an EntityReference display.

Namespace

Drupal\views\Plugin\views\display

Code

public function validate() {
    $errors = parent::validate();
    // Verify that search fields are set up.
    $style = $this->getOption('style');
    if (!isset($style['options']['search_fields'])) {
        $errors[] = $this->t('Display "@display" needs a selected "Search fields" value to work properly. See the settings for the "Entity Reference list" format.', [
            '@display' => $this->display['display_title'],
        ]);
    }
    else {
        // Verify that the search fields used actually exist.
        $fields = array_keys($this->handlers['field']);
        foreach ($style['options']['search_fields'] as $field_alias => $enabled) {
            if ($enabled && !in_array($field_alias, $fields)) {
                $errors[] = $this->t('Display "@display" uses field %field as search field, but the field is no longer present. See the settings for the Entity Reference list format.', [
                    '@display' => $this->display['display_title'],
                    '%field' => $field_alias,
                ]);
            }
        }
    }
    return $errors;
}

API Navigation

  • Drupal Core 11.1.x
  • Topics
  • Classes
  • Functions
  • Constants
  • Globals
  • Files
  • Namespaces
  • Deprecated
  • Services
RSS feed
Powered by Drupal