wiki.techinc.nl/includes/htmlform/HTMLHiddenField.php
Kunal Mehta 6e9b4f0e9c Convert all array() syntax to []
Per wikitech-l consensus:
 https://lists.wikimedia.org/pipermail/wikitech-l/2016-February/084821.html

Notes:
* Disabled CallTimePassByReference due to false positives (T127163)

Change-Id: I2c8ce713ce6600a0bb7bf67537c87044c7a45c4b
2016-02-17 01:33:00 -08:00

66 lines
1.3 KiB
PHP

<?php
class HTMLHiddenField extends HTMLFormField {
protected $outputAsDefault = true;
public function __construct( $params ) {
parent::__construct( $params );
if ( isset( $this->mParams['output-as-default'] ) ) {
$this->outputAsDefault = (bool)$this->mParams['output-as-default'];
}
# Per HTML5 spec, hidden fields cannot be 'required'
# http://www.w3.org/TR/html5/forms.html#hidden-state-%28type=hidden%29
unset( $this->mParams['required'] );
}
public function getHiddenFieldData( $value ) {
$params = [];
if ( $this->mID ) {
$params['id'] = $this->mID;
}
if ( $this->outputAsDefault ) {
$value = $this->mDefault;
}
return [ $this->mName, $value, $params ];
}
public function getTableRow( $value ) {
list( $name, $value, $params ) = $this->getHiddenFieldData( $value );
$this->mParent->addHiddenField( $name, $value, $params );
return '';
}
/**
* @param string $value
* @return string
* @since 1.20
*/
public function getDiv( $value ) {
return $this->getTableRow( $value );
}
/**
* @param string $value
* @return string
* @since 1.20
*/
public function getRaw( $value ) {
return $this->getTableRow( $value );
}
public function getInputHTML( $value ) {
return '';
}
public function canDisplayErrors() {
return false;
}
public function hasVisibleOutput() {
return false;
}
}