Glaisher has uploaded a new change for review.
https://gerrit.wikimedia.org/r/291522
Change subject: Allow providing 'notices' for OOUI HTMLForm fields
......................................................................
Allow providing 'notices' for OOUI HTMLForm fields
Only added implementation for OOUI forms.
Bug: T104423
Change-Id: I512f3936bc3335df1bdf76505cfc39da6be99bed
---
M includes/htmlform/HTMLForm.php
M includes/htmlform/HTMLFormField.php
2 files changed, 30 insertions(+), 0 deletions(-)
git pull ssh://gerrit.wikimedia.org:29418/mediawiki/core
refs/changes/22/291522/1
diff --git a/includes/htmlform/HTMLForm.php b/includes/htmlform/HTMLForm.php
index e891c9c..7e6d74f 100644
--- a/includes/htmlform/HTMLForm.php
+++ b/includes/htmlform/HTMLForm.php
@@ -71,6 +71,11 @@
* '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
diff --git a/includes/htmlform/HTMLFormField.php
b/includes/htmlform/HTMLFormField.php
index 9f5e728..5d73676 100644
--- a/includes/htmlform/HTMLFormField.php
+++ b/includes/htmlform/HTMLFormField.php
@@ -603,6 +603,7 @@
'align' => $this->getLabelAlignOOUI(),
'help' => $helpText !== null ? new OOUI\HtmlSnippet(
$helpText ) : null,
'errors' => $errors,
+ 'notices' => $this->getNotices(),
'infusable' => $infusable,
];
@@ -841,6 +842,30 @@
}
/**
+ * 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
*/
function getLabel() {
--
To view, visit https://gerrit.wikimedia.org/r/291522
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: I512f3936bc3335df1bdf76505cfc39da6be99bed
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/core
Gerrit-Branch: master
Gerrit-Owner: Glaisher <[email protected]>
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits