* 'help-messages' -- array of message keys/objects. As above, each item can
* be an array of msg key and then parameters.
* Overwrites 'help'.
+ * 'notice' -- message text for a message to use as a notice in the field.
+ * Currently used by OOUI form fields only.
+ * 'notice-messages' -- array of message keys/objects to use for notice.
+ * Overrides 'notice'.
+ * 'notice-message' -- message key or object to use as a notice.
* 'required' -- passed through to the object, indicating that it
* is a required field.
* 'size' -- the length of text fields
$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,
];
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
*/