MediaWiki  master
VFormHTMLForm.php
Go to the documentation of this file.
1 <?php
2 
25 
31 class VFormHTMLForm extends HTMLForm {
36  protected $mWrapperLegend = false;
37 
38  protected $displayFormat = 'vform';
39 
40  public static function loadInputFromParameters( $fieldname, $descriptor,
41  HTMLForm $parent = null
42  ) {
43  $field = parent::loadInputFromParameters( $fieldname, $descriptor, $parent );
44  $field->setShowEmptyLabel( false );
45  return $field;
46  }
47 
48  public function getHTML( $submitResult ) {
49  // This is required for VForm HTMLForms that use that style regardless
50  // of wgUseMediaWikiUIEverywhere (since they pre-date it).
51  // When wgUseMediaWikiUIEverywhere is removed, this should be consolidated
52  // with the addModuleStyles in SpecialPage->setHeaders.
53  $this->getOutput()->addModuleStyles( [
54  'mediawiki.ui',
55  'mediawiki.ui.button',
56  'mediawiki.ui.input',
57  'mediawiki.ui.checkbox',
58  ] );
59 
60  return parent::getHTML( $submitResult );
61  }
62 
66  protected function formatField( HTMLFormField $field, $value ) {
67  return $field->getVForm( $value );
68  }
69 
70  protected function getFormAttributes() {
71  return [ 'class' => [ 'mw-htmlform', 'mw-ui-vform', 'mw-ui-container' ] ] +
72  parent::getFormAttributes();
73  }
74 
75  public function wrapForm( $html ) {
76  // Always discard $this->mWrapperLegend
77  return Html::rawElement( 'form', $this->getFormAttributes(), $html );
78  }
79 }
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
Compact stacked vertical format for forms.
formatField(HTMLFormField $field, $value)
Generate the HTML for an individual field in the current display format.1.41 Stability: stableto over...
getHTML( $submitResult)
Returns the raw HTML generated by the form.
getFormAttributes()
Get HTML attributes for the <form> tag.
bool $mWrapperLegend
Wrapper and its legend are never generated in VForm mode.
static loadInputFromParameters( $fieldname, $descriptor, HTMLForm $parent=null)
Initialise a new Object for the field.
wrapForm( $html)
Wrap the form innards in an actual "<form>" element.