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 | 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 | |
61 | /** |
62 | * @inheritDoc |
63 | */ |
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 | |
79 | /** @deprecated class alias since 1.42 */ |
80 | class_alias( VFormHTMLForm::class, 'VFormHTMLForm' ); |