You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+2-1Lines changed: 2 additions & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -261,7 +261,8 @@ When returning error mappings, they need to have the following format:
261
261
{
262
262
"container_id":"dom-id-without-#", // the ID of the error container you want to append this error message to
263
263
"element_to_invalidate_id":"dom-id-without-#", // the ID of the input that should be marked as invalid
264
-
"message":"The error message to render",
264
+
"message":"The error message to render", // The plaintext message used for the error
265
+
"html_content":"<strong>Rich</strong> Markup", // an OPTIONAL HTML string that will be parsed using `DOMParser` and used as the message. If present, `message` is ignored
265
266
"type":"error-type-key", //The identifier for what type of error this is
Copy file name to clipboardExpand all lines: src/error-mapping.js
+9-1Lines changed: 9 additions & 1 deletion
Original file line number
Diff line number
Diff line change
@@ -13,6 +13,7 @@ import {
13
13
import{
14
14
clearErrorListsInForm,
15
15
errorMessageListItem,
16
+
errorMessageListItemWithHTML,
16
17
markErrorTypeAsVisible
17
18
}from'./rendering.js'
18
19
@@ -30,6 +31,7 @@ import {
30
31
* @param {string} errors[].container_id - The ID of the container this error message should be rendered in
31
32
* @param {string} errors[].element_id - The ID of the element to call {@link setValidityStateAttributes} with `false` for
32
33
* @param {string} errors[].message - the error message
34
+
* @param {string} errors[].html_content - An optional HTML string that can be used to render rich markup in an error message. If present, `message` is ignored
33
35
* @param {string} errors[].type - the value for `data-pf-error-type` that represents the type of error this is
34
36
*
35
37
* @example
@@ -74,7 +76,13 @@ export function applyErrorMappingToForm(form, errors) {
Copy file name to clipboardExpand all lines: src/rendering.js
+18Lines changed: 18 additions & 0 deletions
Original file line number
Diff line number
Diff line change
@@ -70,6 +70,24 @@ export function errorMessageListItem(message, type) {
70
70
returnclone
71
71
}
72
72
73
+
/**
74
+
* Clones the {@link errorListItemTemplate}, parsing the given HTML string and inserting it into the element with `[data-pf-error-message]` to the message,
75
+
* and setting the `data-pf-error-type` to the given type.
76
+
*
77
+
* @params {string} htmlString the HTML content to render in the string
78
+
* @params {string} type the value that will be used for `data-pf-error-type``
0 commit comments