Pollenwiki-rot.png

MediaWiki:Contactpage-pagetext: Unterschied zwischen den Versionen

Aus Pollen-Wiki
Zur Navigation springen Zur Suche springen
KKeine Bearbeitungszusammenfassung
KKeine Bearbeitungszusammenfassung
Zeile 1: Zeile 1:
Mit diesem Formular kannst du uns Nachrichten zukommen lassen.
Mit diesem Formular kannst du uns Nachrichten zukommen lassen.
<?php
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';

Version vom 26. Oktober 2018, 17:41 Uhr

Mit diesem Formular kannst du uns Nachrichten zukommen lassen. <?php

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';