Debian Codegraph @

vendor/oojs/oojs-ui/php/widgets/HiddenInputWidget.php

raw
1 <?php
2
3 namespace OOUI;
4
5 /**
6 * Data widget intended for creating 'hidden'-type inputs.
7 */
8 class HiddenInputWidget extends Widget {
9
10 /**
11 * @var string
12 */
13 public static $tagName = 'input';
14
15 /**
16 * DataWidget constructor.
17 *
18 * @param array $config Configuration options
19 * - string $config['value'] The data the input contains. (default: '')
20 * - string $config['name'] The name of the hidden input. (default: '')
21 */
22 public function __construct( array $config ) {
23 // Parent constructor
24 parent::__construct( $config );
25
26 // Initialization
27 $this->setAttributes( [
28 'type' => 'hidden',
29 'value' => $config['value'] ?? '',
30 'name' => $config['name'] ?? '',
31 ] );
32 $this->removeAttributes( [ 'aria-disabled' ] );
33 }
34
35 /** @inheritDoc */
36 public function getConfig( &$config ) {
37 $config['value'] = $this->getAttribute( 'value' );
38 $config['name'] = $this->getAttribute( 'name' );
39 return parent::getConfig( $config );
40 }
41 }