X-Git-Url: https://git.heureux-cyclage.org/?a=blobdiff_plain;f=includes%2Fhtmlform%2Ffields%2FHTMLMultiSelectField.php;h=e8a7e992caf81ca1110b633f4f0688b017b7394c;hb=4df0c71911500466a6330b8fe29c623ef5b51e41;hp=09bacadb69397b4f8c1a61c87421e8f6b9eadece;hpb=fc5dced1ce8151b0354e0efda28a7542713f9cbe;p=lhc%2Fweb%2Fwiklou.git diff --git a/includes/htmlform/fields/HTMLMultiSelectField.php b/includes/htmlform/fields/HTMLMultiSelectField.php index 09bacadb69..e9ecc40f10 100644 --- a/includes/htmlform/fields/HTMLMultiSelectField.php +++ b/includes/htmlform/fields/HTMLMultiSelectField.php @@ -22,8 +22,7 @@ class HTMLMultiSelectField extends HTMLFormField implements HTMLNestedFilterable $this->mParams['disabled-options'] = []; } - // For backwards compatibility, also handle the old way with 'cssclass' => 'mw-chosen' - if ( isset( $params['dropdown'] ) || strpos( $this->mClass, 'mw-chosen' ) !== false ) { + if ( isset( $params['dropdown'] ) ) { $this->mClass .= ' mw-htmlform-dropdown'; } @@ -102,10 +101,10 @@ class HTMLMultiSelectField extends HTMLFormField implements HTMLNestedFilterable if ( $this->mParent instanceof OOUIHTMLForm ) { throw new MWException( 'HTMLMultiSelectField#getOneCheckbox() is not supported' ); } else { - $elementFunc = [ 'Html', $this->mOptionsLabelsNotFromMessage ? 'rawElement' : 'element' ]; + $elementFunc = [ Html::class, $this->mOptionsLabelsNotFromMessage ? 'rawElement' : 'element' ]; $checkbox = Xml::check( "{$this->mName}[]", $checked, $attribs ) . - ' ' . + "\u{00A0}" . call_user_func( $elementFunc, 'label', [ 'for' => $attribs['id'] ], @@ -214,10 +213,14 @@ class HTMLMultiSelectField extends HTMLFormField implements HTMLNestedFilterable * @return string|array */ public function loadDataFromRequest( $request ) { - if ( $this->isSubmitAttempt( $request ) ) { + $fromRequest = $request->getArray( $this->mName, [] ); + // Fetch the value in either one of the two following case: + // - we have a valid submit attempt (form was just submitted) + // - we have a value (an URL manually built by the user, or GET form with no wpFormIdentifier) + if ( $this->isSubmitAttempt( $request ) || $fromRequest ) { // Checkboxes are just not added to the request arrays if they're not checked, // so it's perfectly possible for there not to be an entry at all - return $request->getArray( $this->mName, [] ); + return $fromRequest; } else { // That's ok, the user has not yet submitted the form, so show the defaults return $this->getDefault();