Spage has uploaded a new change for review. https://gerrit.wikimedia.org/r/213786
Change subject: Add HTMLForm example code to special page ...................................................................... Add HTMLForm example code to special page I pasted in the code from https://www.mediawiki.org/wiki/HTMLForm#Example_usage , and converted to use 'ooui' layout, with bugs. Bug: T100401 Change-Id: I051c11f7327dff84c19e141a44c97897bcdd5736 --- M BoilerPlate/specials/SpecialHelloWorld.php 1 file changed, 64 insertions(+), 0 deletions(-) git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/examples refs/changes/86/213786/1 diff --git a/BoilerPlate/specials/SpecialHelloWorld.php b/BoilerPlate/specials/SpecialHelloWorld.php index 304dd90..1fb13f2 100644 --- a/BoilerPlate/specials/SpecialHelloWorld.php +++ b/BoilerPlate/specials/SpecialHelloWorld.php @@ -25,6 +25,70 @@ $out->addHelpLink( 'How to become a MediaWiki hacker' ); $out->addWikiMsg( 'boilerplate-helloworld-intro' ); + + $formDescriptor = array( + 'myfield1' => array( + 'section' => 'section1/subsection', + 'label-message' => 'testform-myfield1', + 'type' => 'text', + 'default' => 'Meep', + ), + 'myfield2' => array( + 'section' => 'section1', + 'label-message' => 'testform-myfield2', + 'class' => 'HTMLTextField', // same as type 'text' + ), + 'myfield3' => array( + 'class' => 'HTMLTextField', + 'label' => 'Foo bar baz', + ), + 'myfield4' => array( + 'class' => 'HTMLCheckField', + 'label' => 'This be a pirate checkbox', + 'default' => true, + ), + 'omgaselectbox' => array( + 'class' => 'HTMLSelectField', + 'label' => 'Select an oooption', + 'options' => array( + 'pirate' => 'Pirates', + 'ninja' => 'Ninjas', + 'ninjars' => 'Back to the NINJAR!' + ), + ), + 'omgmultiselect' => array( + 'class' => 'HTMLMultiSelectField', + 'label' => 'Weapons to use', + 'options' => array( 'Cannons' => 'cannon', 'Swords' => 'sword' ), + 'default' => array( 'sword' ), + ), + 'radiolol' => array( + 'class' => 'HTMLRadioField', + 'label' => 'Who do you like?', + 'options' => array( + 'pirates' => 'Pirates', + 'ninjas' => 'Ninjas', + 'both' => 'Both' + ), + 'default' => 'pirates', + ), + ); + + // $htmlForm = new HTMLForm( $formDescriptor, $this->getContext(), 'testform' ); + $htmlForm = HTMLForm::factory( 'ooui', $formDescriptor, $this->getContext(), 'testform' ); + + $htmlForm->setSubmitText( 'Foo submit' ); + $htmlForm->setSubmitCallback( array( 'SpecialTestForm', 'trySubmit' ) ); + + $htmlForm->show(); + } + + static function trySubmit( $formData ) { + if ( $formData['myfield1'] == 'Fleep' ) { + return true; + } + + return 'HAHA FAIL'; } protected function getGroupName() { -- To view, visit https://gerrit.wikimedia.org/r/213786 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: newchange Gerrit-Change-Id: I051c11f7327dff84c19e141a44c97897bcdd5736 Gerrit-PatchSet: 1 Gerrit-Project: mediawiki/extensions/examples Gerrit-Branch: master Gerrit-Owner: Spage <[email protected]> _______________________________________________ MediaWiki-commits mailing list [email protected] https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits
