如何覆盖 Plone 敏捷行为中字段的默认值?
我们要求敏捷内容类型从导航行为中排除,但 exclude_from_nav
字段的默认值为 True
。在 plone.app.dexterity.behaviors.exclfromnav.IExcludeFromNavigation
行为中,它默认为 False
。
显然,我可以创建自己的行为,复制除默认值之外的 IExcludeFromNavigation
,但我想知道是否有一种基于重用 IExcludeFromNavigation
的方法来做到这一点。我们还有其他使用 IExcludeFromNavigation
的内容类型,但我们确实希望将其默认为 False
。
我们使用 Plone 4.1rc3 和 Dexterity 1.0
We have a requirement for a dexterity content type to have exclude from navigation behaviour but for the exclude_from_nav
field's default value to be True
. In the behaviour plone.app.dexterity.behaviors.exclfromnav.IExcludeFromNavigation
it defaults to False
.
Obviously I could create my own behaviour that copies IExcludeFromNavigation
except for the default value but I was wondering if there was a way to do this based on reusing IExcludeFromNavigation
. We have other content types that use IExcludeFromNavigation
where we do want it to default to False
.
We're using Plone 4.1rc3 and Dexterity 1.0
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
请参阅http://plone.org/products/dexterity/documentation/ Manual/developer-manual/advanced/defaults 和 http://pypi.python.org/pypi/plone.directives.form#value-adapters,但基本上:
干杯,
马丁
See http://plone.org/products/dexterity/documentation/manual/developer-manual/advanced/defaults and http://pypi.python.org/pypi/plone.directives.form#value-adapters, but basically:
Cheers,
Martin
我使用 plone.directives.form 装饰器来完成这项工作。
我已将其添加到我的行为模块之一。
我在configure.zcml中也有以下内容
感谢Martin提供的大量线索,尽管他的回答并没有完全解决我的问题。这对我来说有点像黑客 - 一个更优雅的解决方案会很好。
I have this working using a
plone.directives.form
decorator.I've added this to one of my behaviour modules.
I also have the following in configure.zcml
Thanks to Martin for the large clue although his answer didn't quite solve my problem. This feels like a bit of a hack to me - a more elegant solution would be nice.