Pollenwiki-rot.png

MediaWiki:Contactpage-pagetext: Unterschied zwischen den Versionen

Aus Pollen-Wiki
Zur Navigation springen Zur Suche springen
KKeine Bearbeitungszusammenfassung
KKeine Bearbeitungszusammenfassung
 
(16 dazwischenliegende Versionen desselben Benutzers werden nicht angezeigt)
Zeile 1: Zeile 1:
Mit diesem Formular kannst du uns Nachrichten zukommen lassen.
[[Datei:Banner.jpg|710px]]<br><br>
<?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';

Aktuelle Version vom 15. Dezember 2023, 11:24 Uhr

Banner.jpg