Skip to main content
Drupal API
User account menu
  • Log in

Breadcrumb

  1. Drupal Core 11.1.x
  2. Hidden.php

class 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

  • class \Drupal\Component\Plugin\PluginBase implements \Drupal\Component\Plugin\PluginInspectionInterface, \Drupal\Component\Plugin\DerivativeInspectionInterface
    • class \Drupal\Core\Plugin\PluginBase extends \Drupal\Component\Plugin\PluginBase uses \Drupal\Core\StringTranslation\StringTranslationTrait, \Drupal\Core\DependencyInjection\DependencySerializationTrait, \Drupal\Core\Messenger\MessengerTrait
      • class \Drupal\Core\Render\Element\RenderElementBase extends \Drupal\Core\Plugin\PluginBase implements \Drupal\Core\Render\Element\ElementInterface
        • class \Drupal\Core\Render\Element\FormElementBase extends \Drupal\Core\Render\Element\RenderElementBase implements \Drupal\Core\Render\Element\FormElementInterface
          • class \Drupal\Core\Render\Element\Hidden extends \Drupal\Core\Render\Element\FormElementBase

Expanded class hierarchy of Hidden

See also

\Drupal\Core\Render\Element\Value

101 string references to 'Hidden'
BaseFieldDefinition::setDisplayConfigurable in core/lib/Drupal/Core/Field/BaseFieldDefinition.php
Sets whether the display for the field can be configured.
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
claro_form_alter in core/themes/claro/claro.theme
Implements hook_form_alter().
claro_preprocess_views_exposed_form in core/themes/claro/claro.theme
Implements hook_preprocess_HOOK() for views_exposed_form.
CommentLinkBuilder::buildCommentedEntityLinks in core/modules/comment/src/CommentLinkBuilder.php

... 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. 5
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

API Navigation

  • Drupal Core 11.1.x
  • Topics
  • Classes
  • Functions
  • Constants
  • Globals
  • Files
  • Namespaces
  • Deprecated
  • Services
RSS feed
Powered by Drupal