You are here

public static function Dazzler::addDefaultThemeProperties in Formdazzle! 2.x

Adds default theme and theme_wrappers info to form elements.

The Drupal\Core\Render\Renderer::doRender() function adds the default properties for each element type. Since these sometimes include #theme and #theme_wrappers, we want to use those now, so we add those two properties now and let render() handle the other default properties later.

Parameters

array $element: The form or form element.

2 calls to Dazzler::addDefaultThemeProperties()
Dazzler::traverse in src/Dazzler.php
A recursive helper function to traverse all form element children.
DazzlerTest::testAddDefaultThemeProperties in tests/src/Unit/DazzlerTest.php
@covers ::addDefaultThemeProperties

File

src/Dazzler.php, line 192

Class

Dazzler
A class providing methods to modify Drupal form elements.

Namespace

Drupal\formdazzle

Code

public static function addDefaultThemeProperties(array &$element) {
  if (isset($element['#type'])) {
    $default_theme_properties = array_intersect_key(\Drupal::service('element_info')
      ->getInfo($element['#type']), [
      '#theme' => TRUE,
      '#theme_wrappers' => TRUE,
    ]);
    $element += $default_theme_properties;
  }
}