// FIXME This only works for forms with no subsections
if ( $fieldset instanceof OOUI\FieldsetLayout ) {
$classes = [ 'mw-htmlform-ooui-header' ];
- if ( !$this->mHeader ) {
- $classes[] = 'mw-htmlform-ooui-header-empty';
- }
if ( $this->oouiErrors ) {
$classes[] = 'mw-htmlform-ooui-header-errors';
}
- $fieldset->addItems( [
- new OOUI\FieldLayout(
- new OOUI\LabelWidget( [ 'label' => new OOUI\HtmlSnippet( $this->mHeader ) ] ),
- [
- 'align' => 'top',
- 'errors' => $this->oouiErrors,
- 'classes' => $classes,
- ]
- )
- ], 0 );
+ if ( $this->mHeader || $this->oouiErrors ) {
+ // if there's no header, don't create an (empty) LabelWidget, simply use a placeholder
+ if ( $this->mHeader ) {
+ $element = new OOUI\LabelWidget( [ 'label' => new OOUI\HtmlSnippet( $this->mHeader ) ] );
+ } else {
+ $element = new OOUI\Widget( [] );
+ }
+ $fieldset->addItems( [
+ new OOUI\FieldLayout(
+ $element,
+ [
+ 'align' => 'top',
+ 'errors' => $this->oouiErrors,
+ 'classes' => $classes,
+ ]
+ )
+ ], 0 );
+ }
}
return $fieldset;
}
margin: 1em 0;
}
-.oo-ui-fieldLayout.mw-htmlform-ooui-header-empty,
-.oo-ui-fieldLayout.mw-htmlform-ooui-header-empty .oo-ui-fieldLayout-body {
- display: none;
-}
-
-.oo-ui-fieldLayout.mw-htmlform-ooui-header-errors {
- /* Override 'display: none' from above */
- display: block;
-}
-
.mw-htmlform-ooui .mw-htmlform-submit-buttons {
margin-top: 1em;
}