Skip to content

Commit

Permalink
Merge pull request #393 from codeconsole/6.0.x-fix-checkbox
Browse files Browse the repository at this point in the history
Proper formatting of checkbox for bootstrap 5
  • Loading branch information
codeconsole authored Jan 14, 2025
2 parents 8ff774d + 0600734 commit ca9fbb8
Showing 1 changed file with 13 additions and 2 deletions.
15 changes: 13 additions & 2 deletions grails-app/taglib/grails/plugin/formfields/FormFieldsTagLib.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -713,9 +713,20 @@ class FormFieldsTagLib {
}
}

// TODO: https://github.com/gpc/fields/issues/392
boolean datePicker = model.type in [Date, Calendar, java.sql.Date, java.sql.Time, LocalDate, LocalDateTime]
if (!datePicker) {
attrs.remove('selectDateClass')
}
boolean checkBox = model.type in [boolean, Boolean]
String checkBoxClass = attrs.remove('checkBoxClass')
if (checkBox && checkBoxClass) {
attrs['class'] = checkBoxClass
}

if (model.type in [String, null]) {
return renderStringInput(model, attrs)
} else if (model.type in [boolean, Boolean]) {
} else if (checkBox) {
return g.checkBox(attrs)
} else if (model.type.isPrimitive() || model.type in Number) {
return renderNumericInput(propertyAccessor, model, attrs)
Expand All @@ -727,7 +738,7 @@ class FormFieldsTagLib {
return renderAssociationInput(model, attrs)
} else if (oneToMany) {
return renderOneToManyInput(model, attrs)
} else if (model.type in [Date, Calendar, java.sql.Date, java.sql.Time, LocalDate, LocalDateTime]) {
} else if (datePicker) {
return renderDateTimeInput(model, attrs)
} else if (model.type in [byte[], Byte[], Blob]) {
return g.field(attrs + [type: "file"])
Expand Down

0 comments on commit ca9fbb8

Please sign in to comment.