function FormBuilder::isElementAccessible

Determines if the element is accessible based on the #access property.

Parameters

array $element: A renderable array element.

Return value

bool TRUE if the element should be considered accessible.

1 call to FormBuilder::isElementAccessible()
FormBuilder::handleInputElement in core/lib/Drupal/Core/Form/FormBuilder.php
Adds the #name and #value properties of an input element before rendering.

File

core/lib/Drupal/Core/Form/FormBuilder.php, line 198

Class

FormBuilder
Provides form building and processing.

Namespace

Drupal\Core\Form

Code

protected function isElementAccessible(array $element) : bool {
  // Elements are accessible by default.
  if (!isset($element['#access'])) {
    return TRUE;
  }
  // Check for #access as an AccessResultInterface object.
  if ($element['#access'] instanceof AccessResultInterface) {
    return $element['#access']->isAllowed();
  }
  // Otherwise, #access must be a boolean.
  return $element['#access'] === TRUE;
}

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