Merge "Align "What's this" vertically"
[lhc/web/wiklou.git] / includes / htmlform / OOUIHTMLForm.php
index 549edde..e47de61 100644 (file)
@@ -66,7 +66,10 @@ class OOUIHTMLForm extends HTMLForm {
                        }
 
                        if ( isset( $this->mSubmitTooltip ) ) {
-                               $attribs += Linker::tooltipAndAccesskeyAttribs( $this->mSubmitTooltip );
+                               $attribs += [
+                                       'title' => Linker::titleAttrib( $this->mSubmitTooltip ),
+                                       'accessKey' => Linker::accesskey( $this->mSubmitTooltip ),
+                               ];
                        }
 
                        $attribs['classes'] = [ 'mw-htmlform-submit' ];
@@ -177,7 +180,7 @@ class OOUIHTMLForm extends HTMLForm {
                        'items' => $fieldsHtml,
                ];
                if ( $sectionName ) {
-                       $config['id'] = Sanitizer::escapeId( $sectionName );
+                       $config['id'] = Sanitizer::escapeIdForAttribute( $sectionName );
                }
                if ( is_string( $this->mWrapperLegend ) ) {
                        $config['label'] = $this->mWrapperLegend;
@@ -191,15 +194,16 @@ class OOUIHTMLForm extends HTMLForm {
         * @return string
         */
        public function getErrorsOrWarnings( $elements, $elementsType ) {
-               if ( !in_array( $elementsType, [ 'error', 'warning' ] ) ) {
+               if ( $elements === '' ) {
+                       return '';
+               }
+
+               if ( !in_array( $elementsType, [ 'error', 'warning' ], true ) ) {
                        throw new DomainException( $elementsType . ' is not a valid type.' );
                }
-               if ( !$elements ) {
-                       $errors = [];
-               } elseif ( $elements instanceof Status ) {
-                       if ( $elements->isGood() ) {
-                               $errors = [];
-                       } else {
+               $errors = [];
+               if ( $elements instanceof Status ) {
+                       if ( !$elements->isGood() ) {
                                $errors = $elements->getErrorsByType( $elementsType );
                                foreach ( $errors as &$error ) {
                                        // Input:  [ 'message' => 'foo', 'errors' => [ 'a', 'b', 'c' ] ]
@@ -207,13 +211,12 @@ class OOUIHTMLForm extends HTMLForm {
                                        $error = array_merge( [ $error['message'] ], $error['params'] );
                                }
                        }
-               } elseif ( $elementsType === 'errors' ) {
-                       $errors = $elements;
-                       if ( !is_array( $errors ) ) {
-                               $errors = [ $errors ];
+               } elseif ( $elementsType === 'error' ) {
+                       if ( is_array( $elements ) ) {
+                               $errors = $elements;
+                       } elseif ( is_string( $elements ) ) {
+                               $errors = [ $elements ];
                        }
-               } else {
-                       $errors = [];
                }
 
                foreach ( $errors as &$error ) {