From 1d51b8e3e7ecf06edcd7a4f46168a1882302c4ee Mon Sep 17 00:00:00 2001 From: Scott Murphy Heiberg <scott@alwaysvip.com> Date: Sun, 12 Jan 2025 14:42:56 -0800 Subject: [PATCH 1/3] Proper formatting of checkbox for bootstrap 5 --- .../plugin/formfields/FormFieldsTagLib.groovy | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/grails-app/taglib/grails/plugin/formfields/FormFieldsTagLib.groovy b/grails-app/taglib/grails/plugin/formfields/FormFieldsTagLib.groovy index aeb8cf8d..4a7c3615 100644 --- a/grails-app/taglib/grails/plugin/formfields/FormFieldsTagLib.groovy +++ b/grails-app/taglib/grails/plugin/formfields/FormFieldsTagLib.groovy @@ -700,9 +700,19 @@ class FormFieldsTagLib { } } + boolean dateWidget = model.type in [Date, Calendar, java.sql.Date, java.sql.Time, LocalDate, LocalDateTime] + if (!dateWidget) { + 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) @@ -714,7 +724,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 (dateWidget) { return renderDateTimeInput(model, attrs) } else if (model.type in [byte[], Byte[], Blob]) { return g.field(attrs + [type: "file"]) From c0e0246eac26c6fba2a8fcae834bac39549b559a Mon Sep 17 00:00:00 2001 From: Scott Murphy Heiberg <scott@alwaysvip.com> Date: Sun, 12 Jan 2025 14:51:16 -0800 Subject: [PATCH 2/3] use consistant naming --- .../taglib/grails/plugin/formfields/FormFieldsTagLib.groovy | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/grails-app/taglib/grails/plugin/formfields/FormFieldsTagLib.groovy b/grails-app/taglib/grails/plugin/formfields/FormFieldsTagLib.groovy index 4a7c3615..36e114c4 100644 --- a/grails-app/taglib/grails/plugin/formfields/FormFieldsTagLib.groovy +++ b/grails-app/taglib/grails/plugin/formfields/FormFieldsTagLib.groovy @@ -700,8 +700,8 @@ class FormFieldsTagLib { } } - boolean dateWidget = model.type in [Date, Calendar, java.sql.Date, java.sql.Time, LocalDate, LocalDateTime] - if (!dateWidget) { + 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] @@ -724,7 +724,7 @@ class FormFieldsTagLib { return renderAssociationInput(model, attrs) } else if (oneToMany) { return renderOneToManyInput(model, attrs) - } else if (dateWidget) { + } else if (datePicker) { return renderDateTimeInput(model, attrs) } else if (model.type in [byte[], Byte[], Blob]) { return g.field(attrs + [type: "file"]) From 0600734721f63284117ee1701d9ca51798c05ed9 Mon Sep 17 00:00:00 2001 From: Scott Murphy Heiberg <scott@alwaysvip.com> Date: Sun, 12 Jan 2025 14:51:35 -0800 Subject: [PATCH 3/3] Add link to TODO --- .../taglib/grails/plugin/formfields/FormFieldsTagLib.groovy | 1 + 1 file changed, 1 insertion(+) diff --git a/grails-app/taglib/grails/plugin/formfields/FormFieldsTagLib.groovy b/grails-app/taglib/grails/plugin/formfields/FormFieldsTagLib.groovy index 36e114c4..cc497115 100644 --- a/grails-app/taglib/grails/plugin/formfields/FormFieldsTagLib.groovy +++ b/grails-app/taglib/grails/plugin/formfields/FormFieldsTagLib.groovy @@ -700,6 +700,7 @@ 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')