3 namespace MediaWiki\HTMLForm\Field
;
5 use MediaWiki\HTMLForm\HTMLFormField
;
10 class HTMLHiddenField
extends HTMLFormField
{
12 protected $outputAsDefault = true;
18 public function __construct( $params ) {
19 parent
::__construct( $params );
21 if ( isset( $this->mParams
['output-as-default'] ) ) {
22 $this->outputAsDefault
= (bool)$this->mParams
['output-as-default'];
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'] );
30 public function getHiddenFieldData( $value ) {
33 $params['id'] = $this->mID
;
36 if ( $this->outputAsDefault
) {
37 $value = $this->mDefault
;
40 return [ $this->mName
, $value, $params ];
43 public function getTableRow( $value ) {
44 [ $name, $value, $params ] = $this->getHiddenFieldData( $value );
45 $this->mParent
->addHiddenField( $name, $value, $params );
50 * @param string $value
54 public function getDiv( $value ) {
55 return $this->getTableRow( $value );
59 * @param string $value
63 public function getRaw( $value ) {
64 return $this->getTableRow( $value );
67 public function getCodex( $value ) {
68 return $this->getTableRow( $value );
71 public function getInputHTML( $value ) {
75 public function canDisplayErrors() {
79 public function hasVisibleOutput() {
84 /** @deprecated class alias since 1.42 */
85 class_alias( HTMLHiddenField
::class, 'HTMLHiddenField' );