6 class HTMLCheckField
extends HTMLFormField
{
7 function getInputHTML( $value ) {
8 global $wgUseMediaWikiUIEverywhere;
10 if ( !empty( $this->mParams
['invert'] ) ) {
14 $attr = $this->getTooltipAndAccessKey();
15 $attr['id'] = $this->mID
;
17 $attr +
= $this->getAttributes( array( 'disabled', 'tabindex' ) );
19 if ( $this->mClass
!== '' ) {
20 $attr['class'] = $this->mClass
;
23 $chkLabel = Xml
::check( $this->mName
, $value, $attr )
25 . Html
::rawElement( 'label', array( 'for' => $this->mID
), $this->mLabel
);
27 if ( $wgUseMediaWikiUIEverywhere ||
$this->mParent
instanceof VFormHTMLForm
) {
28 $chkLabel = Html
::rawElement(
30 array( 'class' => 'mw-ui-checkbox' ),
39 * For a checkbox, the label goes on the right hand side, and is
40 * added in getInputHTML(), rather than HTMLFormField::getRow()
48 * checkboxes don't need a label.
51 protected function needsLabel() {
56 * @param WebRequest $request
60 function loadDataFromRequest( $request ) {
61 $invert = isset( $this->mParams
['invert'] ) && $this->mParams
['invert'];
63 // GetCheck won't work like we want for checks.
64 // Fetch the value in either one of the two following case:
65 // - we have a valid token (form got posted or GET forged by the user)
66 // - checkbox name has a value (false or true), ie is not null
67 if ( $request->getCheck( 'wpEditToken' ) ||
$request->getVal( $this->mName
) !== null ) {
69 ?
!$request->getBool( $this->mName
)
70 : $request->getBool( $this->mName
);
72 return $this->getDefault();