MediaWiki master
VFormHTMLForm.php
Go to the documentation of this file.
1<?php
2
3namespace MediaWiki\HTMLForm;
4
14
21class VFormHTMLForm extends HTMLForm {
26 protected $mWrapperLegend = false;
27
29 protected $displayFormat = 'vform';
30
32 public function __construct( $descriptor, IContextSource $context, $messagePrefix = '' ) {
33 wfDeprecated( __CLASS__, '1.45' );
34 parent::__construct( $descriptor, $context, $messagePrefix );
35 }
36
38 public static function loadInputFromParameters( $fieldname, $descriptor,
39 ?HTMLForm $parent = null
40 ) {
41 $field = parent::loadInputFromParameters( $fieldname, $descriptor, $parent );
42 $field->setShowEmptyLabel( false );
43 return $field;
44 }
45
47 public function getHTML( $submitResult ) {
48 $this->getOutput()->addModuleStyles( [
49 'mediawiki.ui',
50 'mediawiki.ui.button',
51 'mediawiki.ui.input',
52 'mediawiki.ui.checkbox',
53 ] );
54
55 return parent::getHTML( $submitResult );
56 }
57
61 protected function formatField( HTMLFormField $field, $value ) {
62 return $field->getVForm( $value );
63 }
64
66 protected function getFormAttributes() {
67 return [ 'class' => [ 'mw-htmlform', 'mw-ui-vform', 'mw-ui-container' ] ] +
68 parent::getFormAttributes();
69 }
70
72 public function wrapForm( $html ) {
73 // Always discard $this->mWrapperLegend
74 return Html::rawElement( 'form', $this->getFormAttributes(), $html );
75 }
76}
77
79class_alias( VFormHTMLForm::class, 'VFormHTMLForm' );
wfDeprecated( $function, $version=false, $component=false, $callerOffset=2)
Logs a warning that a deprecated feature was used.
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:195
Compact stacked vertical format for forms.
getHTML( $submitResult)
Returns the raw HTML generated by the form.to overridestring HTML
formatField(HTMLFormField $field, $value)
Generate the HTML for an individual field in the current display format.1.41 to override string|Strin...
static loadInputFromParameters( $fieldname, $descriptor, ?HTMLForm $parent=null)
Initialise a new Object for the field.to overrideNot passing (or passing null) for $parent is depreca...
bool $mWrapperLegend
Wrapper and its legend are never generated in VForm mode.
__construct( $descriptor, IContextSource $context, $messagePrefix='')
Build a new HTMLForm from an array of field attributes.to call
getFormAttributes()
Get HTML attributes for the <form> tag.to override array
wrapForm( $html)
Wrap the form innards in an actual "<form>" element.to override string|\OOUI\Tag Wrapped HTML.
This class is a collection of static functions that serve two purposes:
Definition Html.php:43
Interface for objects which can provide a MediaWiki context on request.