namgang opened a new issue, #14251: URL: https://github.com/apache/grails-core/issues/14251
This issue only applies to the grails3 branch. I don't know how to handle a proper pull request, sorry. - Currently it's not possible to exclude persistent properties in f:display - Currently it's not possible to include non-persistent properties in f:display In [FormFieldsTagLib.groovy](https://github.com/grails-fields-plugin/grails-fields/blob/grails3/grails-app/taglib/grails/plugin/formfields/FormFieldsTagLib.groovy), in the closure defining the display tag, replace `def properties = domainClass.persistentProperties.sort(new DomainClassPropertyComparator(domainClass))` by `def properties = resolvePersistentProperties(domainClass, attrs)` The latter method handles exclusions. Note that `render` following this line passes `domainProperties` into the GSP. However, [_list.gsp](https://github.com/grails-fields-plugin/grails-fields/blob/grails3/grails-app/views/templates/_fields/_list.gsp) does not pick up that variable but invokes `domainClass.persistentProperties` again, wasting the work done to select properties. Change to `${domainProperties}` in _list.gsp. That makes 2 changes. So far only bug corrections. The documentation does not mention it, but the fields plugin picks up a static `scaffold` attribute from the domain class, if present. The value of the attribute must be a map. The `resolvePersistentProperties()` method checks that map and uses its `exclude` key, if defined, to exclude properties from the view. It is quite easy to add logic to check an `include` key of the same scaffold static property. It may be used to include non-persistent properties in the view. Add the following code after the three `properties.removeAll` calls in the `resolvePersistentProperties` method. ``` groovy if (scaffoldProp?.include) { def inclusion = domainClass.properties.findAll {prop -> scaffoldProp.include.contains(prop.name) && !properties.find {it.name == prop.name} } properties.addAll(inclusion) } ``` The condition makes sure we don't duplicate a property that's already included. -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected]
