MediaWiki master
HTMLHiddenField.php
Go to the documentation of this file.
1<?php
2
4
6
7/*
8 * @stable to extend
9 */
12 protected $outputAsDefault = true;
13
18 public function __construct( $params ) {
19 parent::__construct( $params );
20
21 if ( isset( $this->mParams['output-as-default'] ) ) {
22 $this->outputAsDefault = (bool)$this->mParams['output-as-default'];
23 }
24
25 # Per HTML5 spec, hidden fields cannot be 'required'
26 # https://www.w3.org/TR/html5/forms.html#hidden-state-%28type=hidden%29
27 unset( $this->mParams['required'] );
28 }
29
30 public function getHiddenFieldData( $value ) {
31 $params = [];
32 if ( $this->mID ) {
33 $params['id'] = $this->mID;
34 }
35
36 if ( $this->outputAsDefault ) {
37 $value = $this->mDefault;
38 }
39
40 return [ $this->mName, $value, $params ];
41 }
42
43 public function getTableRow( $value ) {
44 [ $name, $value, $params ] = $this->getHiddenFieldData( $value );
45 $this->mParent->addHiddenField( $name, $value, $params );
46 return '';
47 }
48
54 public function getDiv( $value ) {
55 return $this->getTableRow( $value );
56 }
57
63 public function getRaw( $value ) {
64 return $this->getTableRow( $value );
65 }
66
67 public function getCodex( $value ) {
68 return $this->getTableRow( $value );
69 }
70
71 public function getInputHTML( $value ) {
72 return '';
73 }
74
75 public function canDisplayErrors() {
76 return false;
77 }
78
79 public function hasVisibleOutput() {
80 return false;
81 }
82}
83
85class_alias( HTMLHiddenField::class, 'HTMLHiddenField' );
array $params
The job parameters.
getInputHTML( $value)
This function must be implemented to return the HTML to generate the input object itself.
hasVisibleOutput()
If this field has a user-visible output or not.
getTableRow( $value)
Get the complete table row for the input, including help text, labels, and whatever.
getCodex( $value)
Get the Codex version of the div.
canDisplayErrors()
True if this field type is able to display errors; false if validation errors need to be displayed in...
The parent class to generate form fields.