X-Git-Url: https://git.heureux-cyclage.org/?a=blobdiff_plain;f=includes%2Fhtmlform%2FOOUIHTMLForm.php;h=66503216336022e455b52dc934832ba3560c62b3;hb=36127c29c2d564cc723b6e1cfccca9ba1a0240c8;hp=46b570d92fd610d08afb5edb0ab4c73a2235e1f5;hpb=1dd2e07276e1deaf431ddb01c92111038f9e2cd6;p=lhc%2Fweb%2Fwiklou.git diff --git a/includes/htmlform/OOUIHTMLForm.php b/includes/htmlform/OOUIHTMLForm.php index 46b570d92f..6650321633 100644 --- a/includes/htmlform/OOUIHTMLForm.php +++ b/includes/htmlform/OOUIHTMLForm.php @@ -191,15 +191,12 @@ class OOUIHTMLForm extends HTMLForm { * @return string */ public function getErrorsOrWarnings( $elements, $elementsType ) { - if ( !in_array( $elementsType, [ 'error', 'warning' ] ) ) { + 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 +204,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 ) { @@ -275,7 +271,7 @@ class OOUIHTMLForm extends HTMLForm { public function wrapForm( $html ) { $form = new OOUI\FormLayout( $this->getFormAttributes() + [ - 'classes' => [ 'mw-htmlform-ooui' ], + 'classes' => [ 'mw-htmlform', 'mw-htmlform-ooui' ], 'content' => new OOUI\HtmlSnippet( $html ), ] );