From 2c64a60e066784ea6994cf75fdadd72b78c6ac3c Mon Sep 17 00:00:00 2001 From: adrian Date: Sun, 8 Oct 2023 22:07:47 +0200 Subject: [PATCH] add 'template' override option to the f:display tag too (so to be able to override "templates._fiedls/list.gsp", the same way it's already possible to do it for f:table to override the "templates._fields.table.gsp") --- .../grails/plugin/formfields/FormFieldsTagLib.groovy | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/grails-app/taglib/grails/plugin/formfields/FormFieldsTagLib.groovy b/grails-app/taglib/grails/plugin/formfields/FormFieldsTagLib.groovy index 22c9cea4..b518e4bc 100644 --- a/grails-app/taglib/grails/plugin/formfields/FormFieldsTagLib.groovy +++ b/grails-app/taglib/grails/plugin/formfields/FormFieldsTagLib.groovy @@ -319,6 +319,7 @@ class FormFieldsTagLib { * @attr order A comma-separated list of properties to include in provided order * @attr except A comma-separated list of properties to exclude * @attr theme Theme name + * @attr template OPTIONAL The template used when rendering the domainClass */ def display = { attrs, body -> attrs = beanStack.innerAttributes + attrs @@ -327,13 +328,15 @@ class FormFieldsTagLib { String property = attrs.remove(PROPERTY_ATTR) String templatesFolder = attrs.remove(TEMPLATES_ATTR) - String theme = attrs.remove(THEME_ATTR) + String theme = attrs.remove(THEME_ATTR) if (property == null) { PersistentEntity domainClass = resolveDomainClass(bean) if (domainClass) { + String template = attrs.remove('template') ?: 'list' + List properties = resolvePersistentProperties(domainClass, attrs) - out << render(template: "/templates/_fields/list", model: [domainClass: domainClass, domainProperties: properties]) { prop -> + out << render(template: "/templates/_fields/$template", model: [domainClass: domainClass, domainProperties: properties]) { prop -> BeanPropertyAccessor propertyAccessor = resolveProperty(bean, prop.name) Map model = buildModel(propertyAccessor, attrs, 'HTML') out << raw(renderDisplayWidget(propertyAccessor, model, attrs, templatesFolder, theme))