MediaWiki  master
HTMLHiddenField.php
Go to the documentation of this file.
1 <?php
2 
4  protected $outputAsDefault = true;
5 
6  public function __construct( $params ) {
7  parent::__construct( $params );
8 
9  if ( isset( $this->mParams['output-as-default'] ) ) {
10  $this->outputAsDefault = (bool)$this->mParams['output-as-default'];
11  }
12 
13  # Per HTML5 spec, hidden fields cannot be 'required'
14  # https://www.w3.org/TR/html5/forms.html#hidden-state-%28type=hidden%29
15  unset( $this->mParams['required'] );
16  }
17 
18  public function getHiddenFieldData( $value ) {
19  $params = [];
20  if ( $this->mID ) {
21  $params['id'] = $this->mID;
22  }
23 
24  if ( $this->outputAsDefault ) {
25  $value = $this->mDefault;
26  }
27 
28  return [ $this->mName, $value, $params ];
29  }
30 
31  public function getTableRow( $value ) {
32  list( $name, $value, $params ) = $this->getHiddenFieldData( $value );
33  $this->mParent->addHiddenField( $name, $value, $params );
34  return '';
35  }
36 
42  public function getDiv( $value ) {
43  return $this->getTableRow( $value );
44  }
45 
51  public function getRaw( $value ) {
52  return $this->getTableRow( $value );
53  }
54 
55  public function getInputHTML( $value ) {
56  return '';
57  }
58 
59  public function canDisplayErrors() {
60  return false;
61  }
62 
63  public function hasVisibleOutput() {
64  return false;
65  }
66 }
HTMLHiddenField\getRaw
getRaw( $value)
Definition: HTMLHiddenField.php:51
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:59
HTMLHiddenField\getHiddenFieldData
getHiddenFieldData( $value)
Definition: HTMLHiddenField.php:18
HTMLHiddenField\$outputAsDefault
$outputAsDefault
Definition: HTMLHiddenField.php:4
HTMLFormField\$mName
$mName
Definition: HTMLFormField.php:13
HTMLFormField
The parent class to generate form fields.
Definition: HTMLFormField.php:7
HTMLFormField\$mDefault
$mDefault
Definition: HTMLFormField.php:20
HTMLFormField\$mID
$mID
Definition: HTMLFormField.php:16
HTMLHiddenField\__construct
__construct( $params)
Initialise the object.
Definition: HTMLHiddenField.php:6
HTMLHiddenField
Definition: HTMLHiddenField.php:3
HTMLHiddenField\getDiv
getDiv( $value)
Definition: HTMLHiddenField.php:42
HTMLHiddenField\hasVisibleOutput
hasVisibleOutput()
If this field has a user-visible output or not.
Definition: HTMLHiddenField.php:63
HTMLHiddenField\getTableRow
getTableRow( $value)
Get the complete table row for the input, including help text, labels, and whatever.
Definition: HTMLHiddenField.php:31
HTMLHiddenField\getInputHTML
getInputHTML( $value)
This function must be implemented to return the HTML to generate the input object itself.
Definition: HTMLHiddenField.php:55