Grails 脚手架 - 在控制器操作中定义 exceptedProperties?
每次从 Grails 基架视图中排除属性的引用都围绕着将它们添加到 create.gsp 和 edit.gsp 中的 exceptedProperties 中。是否可以在控制器操作而不是 gsp 中定义排除的属性,而且并非不明智?
Every reference to excluding properties from Grails scaffolded views revolves around adding them to the excludedProperties in the create.gsp and edit.gsp. Is it possible, and not unwise, to define excluded properties in the controller action rather than in the gsp?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
如果您想阻止字段显示在脚手架视图中,实际上可以通过修改域类的约束闭包来实现。例如:
通过将“display:false”添加到 hideMe 的约束中,它将阻止它在任何支架视图上显示。您还可以设置可编辑、密码、格式等以进一步控制显示的内容。查看有关约束的 Grails 文档以获取更多信息(查看本页底部:http://grails.org/doc/latest/ref/Constraints/Usage.html)
If you want to keep a field from showing up in the scaffolded views, you actually do it by modifying the domain class's constraints closure. For example:
By adding "display:false" to the constraints for hideMe, it will prevent it from even showing on ANY of the scaffolded views. You can also set editable, password, format, etc to further control the ones that do show up. Take a look at the Grails documentation on constraints for more info (look at the bottom of this page: http://grails.org/doc/latest/ref/Constraints/Usage.html )