Skip to content

Commit

Permalink
Merge pull request #378 from codeconsole/5.1.x-widget-invalid-class
Browse files Browse the repository at this point in the history
Fix for invalid class not rendering on widget
  • Loading branch information
codeconsole authored Nov 7, 2024
2 parents 79b6e01 + aa880f9 commit 13f6936
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 13f6936

Please sign in to comment.