OOUIHTMLForm: Wrap help text in OOUI\HtmlSnippet
[lhc/web/wiklou.git] / includes / htmlform / HTMLFormField.php
index 49478fb..3e30d79 100644 (file)
@@ -524,12 +524,20 @@ abstract class HTMLFormField {
                        'mw-htmlform-nolabel' => ( $label === '' )
                );
 
-               $field = Html::rawElement(
-                       'div',
-                       array( 'class' => $outerDivClass ) + $cellAttributes,
-                       $inputHtml . "\n$errors"
-               );
-               $divCssClasses = array( "mw-htmlform-field-$fieldType", $this->mClass, $this->mVFormClass, $errorClass );
+               $horizontalLabel = isset( $this->mParams['horizontal-label'] )
+                       ? $this->mParams['horizontal-label'] : false;
+
+               if ( $horizontalLabel ) {
+                       $field = ' ' . $inputHtml . "\n$errors";
+               } else {
+                       $field = Html::rawElement(
+                               'div',
+                               array( 'class' => $outerDivClass ) + $cellAttributes,
+                               $inputHtml . "\n$errors"
+                       );
+               }
+               $divCssClasses = array( "mw-htmlform-field-$fieldType",
+                       $this->mClass, $this->mVFormClass, $errorClass );
 
                $wrapperAttributes = array(
                        'class' => $divCssClasses,
@@ -577,7 +585,7 @@ abstract class HTMLFormField {
                        'classes' => array( "mw-htmlform-field-$fieldType", $this->mClass, $errorClass ),
                        'align' => $this->getLabelAlignOOUI(),
                        'label' => $this->getLabel(),
-                       'help' => $this->getHelpText(),
+                       'help' => new OOUI\HtmlSnippet( $this->getHelpText() ),
                        'infusable' => $infusable,
                ) );
 
@@ -721,7 +729,7 @@ abstract class HTMLFormField {
        /**
         * Determine the help text to display
         * @since 1.20
-        * @return string
+        * @return string HTML
         */
        public function getHelpText() {
                $helptext = null;
@@ -796,6 +804,8 @@ abstract class HTMLFormField {
 
                $displayFormat = $this->mParent->getDisplayFormat();
                $html = '';
+               $horizontalLabel = isset( $this->mParams['horizontal-label'] )
+                       ? $this->mParams['horizontal-label'] : false;
 
                if ( $displayFormat === 'table' ) {
                        $html =
@@ -803,7 +813,7 @@ abstract class HTMLFormField {
                                        array( 'class' => 'mw-label' ) + $cellAttributes,
                                        Html::rawElement( 'label', $for, $labelValue ) );
                } elseif ( $hasLabel || $this->mShowEmptyLabels ) {
-                       if ( $displayFormat === 'div' ) {
+                       if ( $displayFormat === 'div' && !$horizontalLabel ) {
                                $html =
                                        Html::rawElement( 'div',
                                                array( 'class' => 'mw-label' ) + $cellAttributes,