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