|
|
Zeile 1: |
Zeile 1: |
| <?php
| | Mit diesem Formular kannst du uns Nachrichten zukommen lassen. |
| | |
| class SpecialTestForm extends SpecialPage {
| |
| public function __construct() {
| |
| parent::__construct( 'TestForm' );
| |
| }
| |
| | |
| public function execute( $par ) {
| |
| $this->getOutput()->setPageTitle( 'Test form' );
| |
| | |
| $formDescriptor = [
| |
| 'myfield1' => [
| |
| 'section' => 'section1/subsection',
| |
| 'label-message' => 'testform-myfield1',
| |
| 'type' => 'text',
| |
| 'default' => 'Meep',
| |
| ],
| |
| 'myfield2' => [
| |
| 'section' => 'section1',
| |
| 'label-message' => 'testform-myfield2',
| |
| 'class' => 'HTMLTextField', // same as type 'text'
| |
| ],
| |
| 'myfield3' => [
| |
| 'class' => 'HTMLTextField',
| |
| 'label' => 'Foo bar baz',
| |
| ],
| |
| 'myfield4' => [
| |
| 'class' => 'HTMLCheckField',
| |
| 'label' => 'This be a pirate checkbox',
| |
| 'default' => true,
| |
| ],
| |
| 'omgaselectbox' => [
| |
| 'class' => 'HTMLSelectField',
| |
| 'label' => 'Select an oooption',
| |
| 'options' => [
| |
| 'Pirates' => 'pirate',
| |
| 'Ninjas' => 'ninja',
| |
| 'Back to the NINJAR!' => 'ninjars',
| |
| ],
| |
| ],
| |
| 'omgmultiselect' => [
| |
| 'class' => 'HTMLMultiSelectField',
| |
| 'label' => 'Weapons to use',
| |
| 'options' => [
| |
| 'Cannons' => 'cannon',
| |
| 'Swords' => 'sword',
| |
| ],
| |
| 'default' => [ 'sword' ],
| |
| ],
| |
| 'radiolol' => [
| |
| 'class' => 'HTMLRadioField',
| |
| 'label' => 'Who do you like?',
| |
| 'options' => [
| |
| 'Pirates' => 'pirates',
| |
| 'Ninjas' => 'ninjas',
| |
| 'Both' => 'both',
| |
| ],
| |
| 'default' => 'pirates',
| |
| ],
| |
| ];
| |
| | |
| $htmlForm = new HTMLForm( $formDescriptor, $this->getContext(), 'testform' );
| |
| | |
| $htmlForm->setSubmitText( 'Foo submit' );
| |
| $htmlForm->setSubmitCallback( [ $this, 'trySubmit' ] );
| |
| | |
| $htmlForm->show();
| |
| }
| |
| | |
| public function trySubmit( $formData ) {
| |
| if ( $formData[ 'myfield1' ] === 'Fleep' ) {
| |
| return true;
| |
| }
| |
| | |
| return 'Fail';
| |
| }
| |
| }
| |
| | |
| $wgSpecialPages['TestForm'] = 'SpecialTestForm';
| |