X-Git-Url: https://git.heureux-cyclage.org/?a=blobdiff_plain;f=includes%2Fhtmlform%2FHTMLFormField.php;h=afbb7d5a8d9e55e65095779f3189f69ff043e10d;hb=e843da420393133438236558b084b80e05100f6a;hp=380b11d44149a77de2b391a73a250fd55348a6b8;hpb=46deecce89b76e2d45e61f5f696928bb859ae324;p=lhc%2Fweb%2Fwiklou.git diff --git a/includes/htmlform/HTMLFormField.php b/includes/htmlform/HTMLFormField.php index 380b11d441..afbb7d5a8d 100644 --- a/includes/htmlform/HTMLFormField.php +++ b/includes/htmlform/HTMLFormField.php @@ -28,7 +28,7 @@ abstract class HTMLFormField { protected $mShowEmptyLabels = true; /** - * @var HTMLForm + * @var HTMLForm|null */ public $mParent; @@ -598,11 +598,17 @@ abstract class HTMLFormField { $error = new OOUI\HtmlSnippet( $error ); } + $notices = $this->getNotices(); + foreach ( $notices as &$notice ) { + $notice = new OOUI\HtmlSnippet( $notice ); + } + $config = [ 'classes' => [ "mw-htmlform-field-$fieldType", $this->mClass ], 'align' => $this->getLabelAlignOOUI(), 'help' => $helpText !== null ? new OOUI\HtmlSnippet( $helpText ) : null, 'errors' => $errors, + 'notices' => $notices, 'infusable' => $infusable, ]; @@ -840,6 +846,30 @@ abstract class HTMLFormField { return $errors; } + /** + * Determine notices to display for the field. + * + * @since 1.28 + * @return string[] + */ + function getNotices() { + $notices = []; + + if ( isset( $this->mParams['notice-message'] ) ) { + $notices[] = $this->getMessage( $this->mParams['notice-message'] )->parse(); + } + + if ( isset( $this->mParams['notice-messages'] ) ) { + foreach ( $this->mParams['notice-messages'] as $msg ) { + $notices[] = $this->getMessage( $msg )->parse(); + } + } elseif ( isset( $this->mParams['notice'] ) ) { + $notices[] = $this->mParams['notice']; + } + + return $notices; + } + /** * @return string HTML */ @@ -1095,7 +1125,13 @@ abstract class HTMLFormField { * @return Message */ protected function getMessage( $value ) { - return Message::newFromSpecifier( $value )->setContext( $this->mParent ); + $message = Message::newFromSpecifier( $value ); + + if ( $this->mParent ) { + $message->setContext( $this->mParent ); + } + + return $message; } /**