class Hidden

Same name and namespace in other branches
  1. 9 core/lib/Drupal/Core/Render/Element/Hidden.php \Drupal\Core\Render\Element\Hidden
  2. 8.9.x core/lib/Drupal/Core/Render/Element/Hidden.php \Drupal\Core\Render\Element\Hidden
  3. 10 core/lib/Drupal/Core/Render/Element/Hidden.php \Drupal\Core\Render\Element\Hidden

Provides a form element for an HTML 'hidden' input element.

Specify either #default_value or #value but not both.

Properties:

  • #default_value: The initial value of the form element. JavaScript may alter the value prior to submission.
  • #value: The value of the form element. The Form API ensures that this value remains unchanged by the browser.

Usage example:

$form['entity_id'] = [
    '#type' => 'hidden',
    '#value' => $entity_id,
];

Hierarchy

Expanded class hierarchy of Hidden

See also

\Drupal\Core\Render\Element\Value

184 string references to 'Hidden'
AjaxTest::testUiAjaxException in core/tests/Drupal/FunctionalJavascriptTests/Ajax/AjaxTest.php
Tests that Ajax errors are visible in the UI.
BaseFieldDefinition::setDisplayConfigurable in core/lib/Drupal/Core/Field/BaseFieldDefinition.php
Sets whether the display for the field can be configured.
block.block.test_block.yml in core/modules/block/tests/modules/block_test/config/install/block.block.test_block.yml
core/modules/block/tests/modules/block_test/config/install/block.block.test_block.yml
block_content_entity_display.yml in core/modules/block_content/migrations/block_content_entity_display.yml
core/modules/block_content/migrations/block_content_entity_display.yml
ClaroEntityDisplayTest::testEntityForm in core/tests/Drupal/FunctionalJavascriptTests/Theme/ClaroEntityDisplayTest.php
Copied from parent.

... See full list

File

core/lib/Drupal/Core/Render/Element/Hidden.php, line 26

Namespace

Drupal\Core\Render\Element
View source
class Hidden extends FormElementBase {
    
    /**
     * {@inheritdoc}
     */
    public function getInfo() {
        $class = static::class;
        return [
            '#input' => TRUE,
            '#process' => [
                [
                    $class,
                    'processAjaxForm',
                ],
            ],
            '#pre_render' => [
                [
                    $class,
                    'preRenderHidden',
                ],
            ],
            '#theme' => 'input__hidden',
        ];
    }
    
    /**
     * Prepares a #type 'hidden' render element for input.html.twig.
     *
     * @param array $element
     *   An associative array containing the properties of the element.
     *   Properties used: #name, #value, #attributes.
     *
     * @return array
     *   The $element with prepared variables ready for input.html.twig.
     */
    public static function preRenderHidden($element) {
        $element['#attributes']['type'] = 'hidden';
        Element::setAttributes($element, [
            'name',
            'value',
        ]);
        return $element;
    }

}

Members

Title Sort descending Modifiers Object type Summary Overriden Title Overrides
FormElementBase::processAutocomplete public static function Adds autocomplete functionality to elements. 1
FormElementBase::processPattern public static function #process callback for #pattern form element property. 1
FormElementBase::validatePattern public static function #element_validate callback for #pattern form element property. 1
FormElementBase::valueCallback public static function Determines how user input is mapped to an element's #value property. Overrides FormElementInterface::valueCallback 17
Hidden::getInfo public function Returns the element properties for this element. Overrides ElementInterface::getInfo 1
Hidden::preRenderHidden public static function Prepares a #type 'hidden' render element for input.html.twig.
PluginInspectionInterface::getPluginDefinition public function Gets the definition of the plugin implementation. 6
PluginInspectionInterface::getPluginId public function Gets the plugin_id of the plugin instance. 2
RenderElementBase::preRenderAjaxForm public static function Adds Ajax information about an element to communicate with JavaScript. 2
RenderElementBase::preRenderGroup public static function Adds members of this group as actual elements for rendering. 2
RenderElementBase::processAjaxForm public static function Form element processing handler for the #ajax form property. 3
RenderElementBase::processGroup public static function Arranges elements into groups. 2
RenderElementBase::setAttributes public static function Sets a form element's class attribute. Overrides ElementInterface::setAttributes 2

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