ViewExecutable::$element

Same name in other branches
  1. 9 core/modules/views/src/ViewExecutable.php \Drupal\views\ViewExecutable::element
  2. 8.9.x core/modules/views/src/ViewExecutable.php \Drupal\views\ViewExecutable::element
  3. 11.x core/modules/views/src/ViewExecutable.php \Drupal\views\ViewExecutable::element

A render array container to store render related information.

For example you can alter the array and attach some asset library or JS settings via the #attached key. This is the required way to add custom CSS or JS.

Type: array

See also

\Drupal\Core\Render\AttachmentsResponseProcessorInterface::processAttachments()

File

core/modules/views/src/ViewExecutable.php, line 447

Class

ViewExecutable
Represents a view as a whole.

Namespace

Drupal\views

Code

public $element = [
    '#attached' => [
        'library' => [
            'views/views.module',
        ],
        'drupalSettings' => [],
    ],
    '#cache' => [],
];

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