Skip to content

Instantly share code, notes, and snippets.

@mainframe98
Created September 5, 2018 15:49
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mainframe98/7da5a4849be7e159049e6e00025dcc45 to your computer and use it in GitHub Desktop.
Save mainframe98/7da5a4849be7e159049e6e00025dcc45 to your computer and use it in GitHub Desktop.
( function ( mw, $, OO ) {
var field = OO.ui.infuse( 'checkfield-box-field' ),
toggleSwitch2 = new OO.ui.ToggleSwitchWidget( {
value: field.getValue()
} );
// Create a FieldsetLayout to layout and label switches
var fieldset = new OO.ui.FieldsetLayout( {
label: 'Toggle switches'
} );
fieldset.addItems( [
new OO.ui.FieldLayout( toggleSwitch2, { label: 'On', align: 'top' } )
] );
$( '#checkfield-box-field' ).append( fieldset.$element );
field.toggle();
}( mediaWiki, jQuery, OO ) );
<?php
class SpecialTest extends FormSpecialPage {
public function __construct() {
parent::__construct( 'Test' );
}
/**
* Get an HTMLForm descriptor array
* @return array
*/
protected function getFormFields() : array {
$this->getOutput()->addModules( 'ext.TestExtension' );
return [
'check' => [
'type' => 'check',
'label' => 'check',
'id' => 'checkfield-box-field'
]
];
}
/**
* Process the form on POST submission.
* @param array $data
* @param HTMLForm $form
* @return bool|string|array|Status As documented for HTMLForm::trySubmit.
*/
public function onSubmit( array $data, HTMLForm $form = null ) {
wfVarDump( $data );
return true;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment