Scaffolding templates have a domainClass property of type org.codehaus.groovy.grails.commons.DefaultGrailsDomainClass. This object has the constrainedProperties property. To have excess for "readonly", you must do this:
Your domain class:
class Contact { static belongsTo = [subscription: Subscription] static constraints = { subscription(nullable: false, attributes: [readonly: true]) } String description }
in the forest template:
def ro = domainClass.constrainedProperties.subscription.attributes.readonly
DefaultGrailsDomainClass has a constructor with an attribute of type Class, maybe you can do this:
def domainClass = new DefaultGrailsDomainClass(Contact.class) def ro = domainClass.constrainedProperties.subscription.attributes.readonly
Perhaps there is a Factory for this, but I do not know.
source share