mParams['invert'] ) ) { $value = !$value; } $attr = $this->getTooltipAndAccessKey(); $attr['id'] = $this->mID; $attr += $this->getAttributes( [ 'disabled', 'tabindex' ] ); if ( $this->mClass !== '' ) { $attr['class'] = $this->mClass; } $attrLabel = [ 'for' => $this->mID ]; if ( isset( $attr['title'] ) ) { // propagate tooltip to label $attrLabel['title'] = $attr['title']; } $isVForm = $this->mParent instanceof VFormHTMLForm; $chkDivider = "\u{00A0}"; $chkLabel = Xml::check( $this->mName, $value, $attr ) . $chkDivider . Html::rawElement( 'label', $attrLabel, $this->mLabel ); if ( $isVForm ) { $chkLabelClass = 'mw-ui-checkbox'; $chkLabel = Html::rawElement( 'div', [ 'class' => $chkLabelClass ], $chkLabel ); } return $chkLabel; } /** * Get the OOUI version of this field. * @stable to override * @since 1.26 * @param string $value * @return \OOUI\CheckboxInputWidget The checkbox widget. */ public function getInputOOUI( $value ) { if ( !empty( $this->mParams['invert'] ) ) { $value = !$value; } $attr = $this->getTooltipAndAccessKeyOOUI(); $attr['id'] = $this->mID; $attr['name'] = $this->mName; $attr += \OOUI\Element::configFromHtmlAttributes( $this->getAttributes( [ 'disabled', 'tabindex' ] ) ); if ( $this->mClass !== '' ) { $attr['classes'] = [ $this->mClass ]; } $attr['selected'] = $value; $attr['value'] = '1'; // Nasty hack, but needed to make this work return new \OOUI\CheckboxInputWidget( $attr ); } public function getInputCodex( $value, $hasErrors ) { if ( !empty( $this->mParams['invert'] ) ) { $value = !$value; } // Attributes for the element. $attribs = $this->getTooltipAndAccessKey(); $attribs['id'] = $this->mID; $attribs += $this->getAttributes( [ 'disabled', 'tabindex' ] ); // The Xml class doesn't support an array of classes, so we have to provide a string. $inputClass = $this->mClass ?? ''; $attribs['class'] = $inputClass . ' cdx-checkbox__input'; // Attributes for the