Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Proper formatting of checkbox for bootstrap 5 #393

Merged
merged 3 commits into from
Jan 14, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 @@ -700,9 +700,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 @@ -714,7 +725,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
Loading