diff --git a/grails-app/taglib/grails/plugin/formfields/FormFieldsTagLib.groovy b/grails-app/taglib/grails/plugin/formfields/FormFieldsTagLib.groovy index 9571ab93..aeb8cf8d 100644 --- a/grails-app/taglib/grails/plugin/formfields/FormFieldsTagLib.groovy +++ b/grails-app/taglib/grails/plugin/formfields/FormFieldsTagLib.groovy @@ -42,6 +42,8 @@ import org.springframework.web.servlet.LocaleResolver import jakarta.servlet.http.HttpServletRequest import java.sql.Blob import java.text.NumberFormat +import java.time.LocalDate +import java.time.LocalDateTime import static FormFieldsTemplateService.toPropertyNameFormat @@ -712,7 +714,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]) { + } else if (model.type in [Date, Calendar, java.sql.Date, java.sql.Time, LocalDate, LocalDateTime]) { return renderDateTimeInput(model, attrs) } else if (model.type in [byte[], Byte[], Blob]) { return g.field(attrs + [type: "file"]) @@ -726,7 +728,7 @@ class FormFieldsTagLib { CharSequence renderDateTimeInput(Map model, Map attrs) { - attrs.precision = model.type == java.sql.Time ? "minute" : "day" + attrs.precision = model.type in [java.sql.Time, LocalDateTime]? "minute" : "day" if (!model.required) { attrs.noSelection = ["": ""] attrs.default = "none" @@ -915,6 +917,8 @@ class FormFieldsTagLib { case Date: case java.sql.Date: case java.sql.Time: + case LocalDate: + case LocalDateTime: g.formatDate(date: model.value) break default: diff --git a/src/test/groovy/grails/plugin/formfields/DefaultInputRenderingSpec.groovy b/src/test/groovy/grails/plugin/formfields/DefaultInputRenderingSpec.groovy index 7c2fce0e..2c616335 100644 --- a/src/test/groovy/grails/plugin/formfields/DefaultInputRenderingSpec.groovy +++ b/src/test/groovy/grails/plugin/formfields/DefaultInputRenderingSpec.groovy @@ -21,6 +21,8 @@ import spock.lang.Shared import spock.lang.Unroll import java.sql.Blob +import java.time.LocalDate +import java.time.LocalDateTime @Unroll class DefaultInputRenderingSpec extends AbstractFormFieldsTagLibSpec implements TagLibUnitTest { @@ -248,6 +250,8 @@ class DefaultInputRenderingSpec extends AbstractFormFieldsTagLibSpec implements Calendar | /select name="prop_day"/ java.sql.Date | /select name="prop_day"/ java.sql.Time | /select name="prop_day"/ + LocalDate | /select name="prop_day"/ + LocalDateTime | /select name="prop_day"/ TimeZone | /