MediaWiki master
CodexHTMLForm.php
Go to the documentation of this file.
1<?php
2
25
31class CodexHTMLForm extends HTMLForm {
32
33 protected $displayFormat = 'codex';
34
35 public static function loadInputFromParameters( $fieldname, $descriptor,
36 HTMLForm $parent = null
37 ) {
38 $field = parent::loadInputFromParameters( $fieldname, $descriptor, $parent );
39 $field->setShowEmptyLabel( false );
40 return $field;
41 }
42
43 public function getHTML( $submitResult ) {
44 $this->getOutput()->addModuleStyles( [
45 'codex-styles',
46 ] );
47
48 return parent::getHTML( $submitResult );
49 }
50
54 protected function formatField( HTMLFormField $field, $value ) {
55 // The "cdx-..." classes are added magically in the Html class. :(
56 return $field->getVForm( $value );
57 }
58
59 protected function getFormAttributes() {
60 $attribs = parent::getFormAttributes();
61 $attribs['class'] = [ 'mw-htmlform', 'mw-htmlform-codex' ];
62 return $attribs;
63 }
64
65 public function wrapForm( $html ) {
66 return Html::rawElement( 'form', $this->getFormAttributes(), $html );
67 }
68}
Codex based HTML form.
wrapForm( $html)
Wrap the form innards in an actual "<form>" element.
getHTML( $submitResult)
Returns the raw HTML generated by the form.
formatField(HTMLFormField $field, $value)
Generate the HTML for an individual field in the current display format.1.41 to override string|Strin...
getFormAttributes()
Get HTML attributes for the <form> tag.
static loadInputFromParameters( $fieldname, $descriptor, HTMLForm $parent=null)
Initialise a new Object for the field.
The parent class to generate form fields.
getVForm( $value)
Get the complete field for the input, including help text, labels, and whatever.
Object handling generic submission, CSRF protection, layout and other logic for UI forms in a reusabl...
Definition HTMLForm.php:158
This class is a collection of static functions that serve two purposes:
Definition Html.php:57