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