Details.php

Same filename in this branch
  1. 11.x core/lib/Drupal/Core/Render/Element/Details.php
Same filename and directory in other branches
  1. 9 core/lib/Drupal/Core/Render/Element/Details.php
  2. 8.9.x core/lib/Drupal/Core/Render/Element/Details.php
  3. 10 core/lib/Drupal/Core/Render/Element/Details.php

Namespace

Drupal\element_info_test\Render\Element

File

core/modules/system/tests/modules/element_info_test/src/Render/Element/Details.php

View source
<?php

declare (strict_types=1);
namespace Drupal\element_info_test\Render\Element;

use Drupal\Core\Render\Attribute\RenderElement;
use Drupal\Core\Render\Element;
use Drupal\Core\Render\Element\RenderElementBase;

/**
 * Provides a render element for a details element.
 *
 * Properties:
 *
 * @property $title
 *   The title of the details container. Defaults to "Details".
 * @property $open
 *   Indicates whether the container should be open by default.
 *   Defaults to FALSE.
 * @property $custom
 *   Confirm that this class has been swapped properly.
 * @property $summary_attributes
 *   An array of attributes to apply to the <summary>
 *   element.
 */
class Details extends RenderElementBase {
  
  /**
   * {@inheritdoc}
   */
  public function getInfo() : array {
    return [
      '#open' => FALSE,
      '#summary_attributes' => [],
      '#custom' => 'Custom',
    ];
  }
  
  /**
   * Adds form element theming to details.
   *
   * @param array $element
   *   An associative array containing the properties and children of the
   *   details.
   *
   * @return array
   *   The modified element.
   */
  public static function preRenderDetails($element) : array {
    Element::setAttributes($element, [
      'custom',
    ]);
    return $element;
  }

}

Classes

Title Deprecated Summary
Details Provides a render element for a details element.

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