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
40 protected $displayFormat = 'vform';
41
42 public static function loadInputFromParameters( $fieldname, $descriptor,
43 HTMLForm $parent = null
44 ) {
45 $field = parent::loadInputFromParameters( $fieldname, $descriptor, $parent );
46 $field->setShowEmptyLabel( false );
47 return $field;
48 }
49
50 public function getHTML( $submitResult ) {
51 $this->getOutput()->addModuleStyles( [
52 'mediawiki.ui',
53 'mediawiki.ui.button',
54 'mediawiki.ui.input',
55 'mediawiki.ui.checkbox',
56 ] );
57
58 return parent::getHTML( $submitResult );
59 }
60
64 protected function formatField( HTMLFormField $field, $value ) {
65 return $field->getVForm( $value );
66 }
67
68 protected function getFormAttributes() {
69 return [ 'class' => [ 'mw-htmlform', 'mw-ui-vform', 'mw-ui-container' ] ] +
70 parent::getFormAttributes();
71 }
72
73 public function wrapForm( $html ) {
74 // Always discard $this->mWrapperLegend
75 return Html::rawElement( 'form', $this->getFormAttributes(), $html );
76 }
77}
78
80class_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:206
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