MediaWiki master
HTMLHiddenField.php
Go to the documentation of this file.
1<?php
2
4
6
7/*
8 * @stable to extend
9 */
11 protected $outputAsDefault = true;
12
17 public function __construct( $params ) {
18 parent::__construct( $params );
19
20 if ( isset( $this->mParams['output-as-default'] ) ) {
21 $this->outputAsDefault = (bool)$this->mParams['output-as-default'];
22 }
23
24 # Per HTML5 spec, hidden fields cannot be 'required'
25 # https://www.w3.org/TR/html5/forms.html#hidden-state-%28type=hidden%29
26 unset( $this->mParams['required'] );
27 }
28
29 public function getHiddenFieldData( $value ) {
30 $params = [];
31 if ( $this->mID ) {
32 $params['id'] = $this->mID;
33 }
34
35 if ( $this->outputAsDefault ) {
36 $value = $this->mDefault;
37 }
38
39 return [ $this->mName, $value, $params ];
40 }
41
42 public function getTableRow( $value ) {
43 [ $name, $value, $params ] = $this->getHiddenFieldData( $value );
44 $this->mParent->addHiddenField( $name, $value, $params );
45 return '';
46 }
47
53 public function getDiv( $value ) {
54 return $this->getTableRow( $value );
55 }
56
62 public function getRaw( $value ) {
63 return $this->getTableRow( $value );
64 }
65
66 public function getCodex( $value ) {
67 return $this->getTableRow( $value );
68 }
69
70 public function getInputHTML( $value ) {
71 return '';
72 }
73
74 public function canDisplayErrors() {
75 return false;
76 }
77
78 public function hasVisibleOutput() {
79 return false;
80 }
81}
82
84class_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.