3 namespace MediaWiki\HTMLForm\Field
;
5 use MediaWiki\Widget\ToggleSwitchWidget
;
7 class HTMLToggleSwitchField
extends HTMLCheckField
{
10 * Get the OOUI version of this field.
13 * @param string $value
14 * @return ToggleSwitchWidget
16 public function getInputOOUI( $value ) {
17 if ( !empty( $this->mParams
['invert'] ) ) {
21 $attr = $this->getTooltipAndAccessKeyOOUI();
22 $attr['id'] = $this->mID
;
23 $attr['name'] = $this->mName
;
25 $attr +
= \OOUI\Element
::configFromHtmlAttributes(
26 $this->getAttributes( [ 'disabled', 'tabindex' ] )
29 if ( $this->mClass
!== '' ) {
30 $attr['classes'] = [ $this->mClass
];
33 // For the underlaying CheckboxInputWidget
34 $attr['selected'] = $value;
37 return new ToggleSwitchWidget( $attr );
43 protected function shouldInfuseOOUI() {
44 // Always infuse, as we want a toggle widget when JS is enabled.
48 protected function getOOUIModules() {
49 return [ 'mediawiki.widgets.ToggleSwitchWidget' ];
53 /** @deprecated class alias since 1.42 */
54 class_alias( HTMLToggleSwitchField
::class, 'HTMLToggleSwitchField' );