Skip to content

Commit

Permalink
add 'template' override option to the f:display tag too (so to be abl…
Browse files Browse the repository at this point in the history
…e 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")
  • Loading branch information
adrian committed Oct 8, 2023
1 parent 8ce11bd commit 2c64a60
Showing 1 changed file with 5 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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))
Expand Down

0 comments on commit 2c64a60

Please sign in to comment.