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

Display tag template #336

Merged
merged 1 commit into from
Jan 6, 2024
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
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