MediaWiki master
HTMLHiddenField.php
Go to the documentation of this file.
1<?php
2
4
6
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
34 public function getHiddenFieldData( $value ) {
35 $params = [];
36 if ( $this->mID ) {
37 $params['id'] = $this->mID;
38 }
39
40 if ( $this->outputAsDefault ) {
41 $value = $this->mDefault;
42 }
43
44 return [ $this->mName, $value, $params ];
45 }
46
48 public function getTableRow( $value ) {
49 [ $name, $value, $params ] = $this->getHiddenFieldData( $value );
50 $this->mParent->addHiddenField( $name, $value, $params );
51 return '';
52 }
53
59 public function getDiv( $value ) {
60 return $this->getTableRow( $value );
61 }
62
68 public function getRaw( $value ) {
69 return $this->getTableRow( $value );
70 }
71
73 public function getCodex( $value ) {
74 return $this->getTableRow( $value );
75 }
76
78 public function getInputHTML( $value ) {
79 return '';
80 }
81
83 public function canDisplayErrors() {
84 return false;
85 }
86
88 public function hasVisibleOutput() {
89 return false;
90 }
91}
92
94class_alias( HTMLHiddenField::class, 'HTMLHiddenField' );
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.If not, it will not be rendered to overridebool
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.1.42string HTML
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.