Silverstripe Version:
4
Question:
I want to add extra classes to the error messages of userforms. How to do this?
<span id="UserForm_Form_34_EditableTextField_60d74-error" class="error message">This field is required</span>
Silverstripe Version:
4
Question:
I want to add extra classes to the error messages of userforms. How to do this?
<span id="UserForm_Form_34_EditableTextField_60d74-error" class="error message">This field is required</span>
I’d also like to know this… did you make any progress with this?
Update: this seems to be controlled from within the .js file
silverstripe/userforms:client/dist/js/userforms.js
specifically the section:
UserForm.prototype.validationOptions = {
ignore: ':hidden,ul',
errorClass: 'error',
errorElement: 'span',
errorPlacement: (error, element) => {
error.addClass('message');
if (element.is(':radio') || element.parents('.checkboxset').length > 0) {
error.appendTo(element.closest('.middleColumn, .field'));
} else if (element.parents('.checkbox').length > 0) {
error.appendTo(element.closest('.field'));
} else {
error.insertAfter(element);
}
},
I’m just not sure (yet) how to hook into this from eg. a custom .js file to modify/extend this. I’m not that familiar with jQuery, so if anyone knows how to do this, that’d be great!
I guess some more documentation in UserForms on how to style the module’s default jQuery validate features would be great!