MediaWiki 1.41.2
HTMLToggleSwitchField.php
Go to the documentation of this file.
1<?php
2
4
6
14 public function getInputOOUI( $value ) {
15 if ( !empty( $this->mParams['invert'] ) ) {
16 $value = !$value;
17 }
18
19 $attr = $this->getTooltipAndAccessKeyOOUI();
20 $attr['id'] = $this->mID;
21 $attr['name'] = $this->mName;
22
23 $attr += OOUI\Element::configFromHtmlAttributes(
24 $this->getAttributes( [ 'disabled', 'tabindex' ] )
25 );
26
27 if ( $this->mClass !== '' ) {
28 $attr['classes'] = [ $this->mClass ];
29 }
30
31 // For the underlaying CheckboxInputWidget
32 $attr['selected'] = $value;
33 $attr['value'] = '1';
34
35 return new ToggleSwitchWidget( $attr );
36 }
37
41 protected function shouldInfuseOOUI() {
42 // Always infuse, as we want a toggle widget when JS is enabled.
43 return true;
44 }
45
46 protected function getOOUIModules() {
47 return [ 'mediawiki.widgets.ToggleSwitchWidget' ];
48 }
49}
A checkbox field.
getTooltipAndAccessKeyOOUI()
Returns the attributes required for the tooltip and accesskey, for OOUI widgets' config.
getAttributes(array $list)
Returns the given attributes from the parameters.
shouldInfuseOOUI()
Whether the field should be automatically infused.Note that all OOUI HTMLForm fields are infusable (y...
getInputOOUI( $value)
Get the OOUI version of this field.
getOOUIModules()
Get the list of extra ResourceLoader modules which must be loaded client-side before it's possible to...
Base class for widgets to warp a checkbox into toggle widget.