mirror of
https://github.com/GSA/notifications-admin.git
synced 2026-02-24 04:10:57 -05:00
Add analytics error tracking to checkbox fields
The existing macros added data attributes to any error message displayed which communicated the error to Google Analytics (if the user had given consent). This re-implements that functionality.
This commit is contained in:
@@ -572,7 +572,14 @@ class govukCheckboxField(govukCheckboxesMixin, BooleanField):
|
||||
# error messages
|
||||
error_message = None
|
||||
if field.errors:
|
||||
error_message = {"text": " ".join(field.errors).strip()}
|
||||
error_message = {
|
||||
"attributes": {
|
||||
"data-module": "track-error",
|
||||
"data-error-type": field.errors[0],
|
||||
"data-error-label": field.name
|
||||
},
|
||||
"text": " ".join(field.errors).strip()
|
||||
}
|
||||
|
||||
params = {
|
||||
'name': field.name,
|
||||
@@ -654,7 +661,14 @@ class govukCheckboxesField(govukCheckboxesMixin, SelectMultipleField):
|
||||
# error messages
|
||||
error_message = None
|
||||
if field.errors:
|
||||
error_message = {"text": " ".join(field.errors).strip()}
|
||||
error_message = {
|
||||
"attributes": {
|
||||
"data-module": "track-error",
|
||||
"data-error-type": field.errors[0],
|
||||
"data-error-label": field.name
|
||||
},
|
||||
"text": " ".join(field.errors).strip()
|
||||
}
|
||||
|
||||
# returns either a list or a hierarchy of lists
|
||||
# depending on how get_items_from_options is implemented
|
||||
|
||||
Reference in New Issue
Block a user