MediaWiki fundraising/REL1_35
HTMLHiddenField.php
Go to the documentation of this file.
1<?php
2
3/*
4 * @stable to extend
5 */
7 protected $outputAsDefault = true;
8
9 /*
10 * @stable to call
11 */
12 public function __construct( $params ) {
13 parent::__construct( $params );
14
15 if ( isset( $this->mParams['output-as-default'] ) ) {
16 $this->outputAsDefault = (bool)$this->mParams['output-as-default'];
17 }
18
19 # Per HTML5 spec, hidden fields cannot be 'required'
20 # https://www.w3.org/TR/html5/forms.html#hidden-state-%28type=hidden%29
21 unset( $this->mParams['required'] );
22 }
23
24 public function getHiddenFieldData( $value ) {
25 $params = [];
26 if ( $this->mID ) {
27 $params['id'] = $this->mID;
28 }
29
30 if ( $this->outputAsDefault ) {
31 $value = $this->mDefault;
32 }
33
34 return [ $this->mName, $value, $params ];
35 }
36
37 public function getTableRow( $value ) {
38 list( $name, $value, $params ) = $this->getHiddenFieldData( $value );
39 $this->mParent->addHiddenField( $name, $value, $params );
40 return '';
41 }
42
48 public function getDiv( $value ) {
49 return $this->getTableRow( $value );
50 }
51
57 public function getRaw( $value ) {
58 return $this->getTableRow( $value );
59 }
60
61 public function getInputHTML( $value ) {
62 return '';
63 }
64
65 public function canDisplayErrors() {
66 return false;
67 }
68
69 public function hasVisibleOutput() {
70 return false;
71 }
72}
The parent class to generate form fields.
getInputHTML( $value)
This function must be implemented to return the HTML to generate the input object itself.
getTableRow( $value)
Get the complete table row for the input, including help text, labels, and whatever.
__construct( $params)
Initialise the object.
canDisplayErrors()
True if this field type is able to display errors; false if validation errors need to be displayed in...
hasVisibleOutput()
If this field has a user-visible output or not.
getHiddenFieldData( $value)