MediaWiki master
VFormHTMLForm.php
Go to the documentation of this file.
1<?php
2
3namespace MediaWiki\HTMLForm;
4
27
33class VFormHTMLForm extends HTMLForm {
38 protected $mWrapperLegend = false;
39
41 protected $displayFormat = 'vform';
42
43 public static function loadInputFromParameters( $fieldname, $descriptor,
44 HTMLForm $parent = null
45 ) {
46 $field = parent::loadInputFromParameters( $fieldname, $descriptor, $parent );
47 $field->setShowEmptyLabel( false );
48 return $field;
49 }
50
51 public function getHTML( $submitResult ) {
52 $this->getOutput()->addModuleStyles( [
53 'mediawiki.ui',
54 'mediawiki.ui.button',
55 'mediawiki.ui.input',
56 'mediawiki.ui.checkbox',
57 ] );
58
59 return parent::getHTML( $submitResult );
60 }
61
65 protected function formatField( HTMLFormField $field, $value ) {
66 return $field->getVForm( $value );
67 }
68
69 protected function getFormAttributes() {
70 return [ 'class' => [ 'mw-htmlform', 'mw-ui-vform', 'mw-ui-container' ] ] +
71 parent::getFormAttributes();
72 }
73
74 public function wrapForm( $html ) {
75 // Always discard $this->mWrapperLegend
76 return Html::rawElement( 'form', $this->getFormAttributes(), $html );
77 }
78}
79
81class_alias( VFormHTMLForm::class, 'VFormHTMLForm' );
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:208
Compact stacked vertical format for forms.
getHTML( $submitResult)
Returns the raw HTML generated by the form.
static loadInputFromParameters( $fieldname, $descriptor, HTMLForm $parent=null)
Initialise a new Object for the field.
formatField(HTMLFormField $field, $value)
Generate the HTML for an individual field in the current display format.1.41 to override string|Strin...
bool $mWrapperLegend
Wrapper and its legend are never generated in VForm mode.
getFormAttributes()
Get HTML attributes for the <form> tag.
wrapForm( $html)
Wrap the form innards in an actual "<form>" element.
This class is a collection of static functions that serve two purposes:
Definition Html.php:56