Localisation updates from https://translatewiki.net.
[mediawiki.git] / includes / htmlform / VFormHTMLForm.php
blob4a7a828be8218ab3655bf73312afc4100ca077d9
1 <?php
3 namespace MediaWiki\HTMLForm;
5 /**
6 * HTML form generation and submission handling, vertical-form style.
8 * This program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License as published by
10 * the Free Software Foundation; either version 2 of the License, or
11 * (at your option) any later version.
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
18 * You should have received a copy of the GNU General Public License along
19 * with this program; if not, write to the Free Software Foundation, Inc.,
20 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
21 * http://www.gnu.org/copyleft/gpl.html
23 * @file
26 use MediaWiki\Html\Html;
28 /**
29 * Compact stacked vertical format for forms.
31 * @stable to extend
33 class VFormHTMLForm extends HTMLForm {
34 /**
35 * Wrapper and its legend are never generated in VForm mode.
36 * @var bool
38 protected $mWrapperLegend = false;
40 /** @inheritDoc */
41 protected $displayFormat = 'vform';
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;
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 ] );
59 return parent::getHTML( $submitResult );
62 /**
63 * @inheritDoc
65 protected function formatField( HTMLFormField $field, $value ) {
66 return $field->getVForm( $value );
69 protected function getFormAttributes() {
70 return [ 'class' => [ 'mw-htmlform', 'mw-ui-vform', 'mw-ui-container' ] ] +
71 parent::getFormAttributes();
74 public function wrapForm( $html ) {
75 // Always discard $this->mWrapperLegend
76 return Html::rawElement( 'form', $this->getFormAttributes(), $html );
80 /** @deprecated class alias since 1.42 */
81 class_alias( VFormHTMLForm::class, 'VFormHTMLForm' );