Skip to content

Commit

Permalink
Fix for invalid class not rendering on widget
Browse files Browse the repository at this point in the history
  • Loading branch information
codeconsole committed Nov 7, 2024
1 parent 79b6e01 commit aa880f9
Showing 1 changed file with 10 additions and 4 deletions.
14 changes: 10 additions & 4 deletions grails-app/taglib/grails/plugin/formfields/FormFieldsTagLib.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -202,10 +202,16 @@ class FormFieldsTagLib {
}
}

List classes = [widgetAttrs['class'] ?: '']
if (model.invalid) classes << (widgetAttrs.remove('invalidClass') ?: '')
if (model.required) classes << (widgetAttrs.remove('requiredClass') ?: '')
widgetAttrs['class'] = classes.join(' ').trim()
List widgetClasses = [widgetAttrs['class'] ?: '']
String cssClass = widgetAttrs.remove('invalidClass')
if (cssClass && model.invalid) {
widgetClasses << cssClass
}
cssClass = widgetAttrs.remove('requiredClass')
if (cssClass && model.required) {
widgetClasses << cssClass
}
widgetAttrs['class'] = widgetClasses.join(' ').trim()
if (widgetAttrs['class'].isEmpty()) {
widgetAttrs.remove('class')
}
Expand Down

0 comments on commit aa880f9

Please sign in to comment.