Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
Total | |
0.00% |
0 / 15 |
|
0.00% |
0 / 5 |
CRAP | |
0.00% |
0 / 1 |
VFormHTMLForm | |
0.00% |
0 / 14 |
|
0.00% |
0 / 5 |
30 | |
0.00% |
0 / 1 |
loadInputFromParameters | |
0.00% |
0 / 3 |
|
0.00% |
0 / 1 |
2 | |||
getHTML | |
0.00% |
0 / 7 |
|
0.00% |
0 / 1 |
2 | |||
formatField | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
getFormAttributes | |
0.00% |
0 / 2 |
|
0.00% |
0 / 1 |
2 | |||
wrapForm | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 |
1 | <?php |
2 | |
3 | namespace MediaWiki\HTMLForm; |
4 | |
5 | /** |
6 | * HTML form generation and submission handling, vertical-form style. |
7 | * |
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. |
12 | * |
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. |
17 | * |
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 |
22 | * |
23 | * @file |
24 | */ |
25 | |
26 | use MediaWiki\Html\Html; |
27 | |
28 | /** |
29 | * Compact stacked vertical format for forms. |
30 | * |
31 | * @stable to extend |
32 | */ |
33 | class VFormHTMLForm extends HTMLForm { |
34 | /** |
35 | * Wrapper and its legend are never generated in VForm mode. |
36 | * @var bool |
37 | */ |
38 | protected $mWrapperLegend = false; |
39 | |
40 | /** @inheritDoc */ |
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 | |
62 | /** |
63 | * @inheritDoc |
64 | */ |
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 | |
80 | /** @deprecated class alias since 1.42 */ |
81 | class_alias( VFormHTMLForm::class, 'VFormHTMLForm' ); |