通过 Dexterity 在字段集之间移动字段
在原型中,为了将字段从字段集(或模式)移动到另一个字段集(或模式),我们可以执行以下操作:
schema['creators'].schemata = 'default'
但是,我没有使用 Dexterity 实现相同的目的。我尝试过使用表单提示。例如:
form.fieldset('default',
fields=['creators']
)
我注意到它不起作用,因为此时“创建者”字段未知。 (尚未评估所有权行为)。
尽管如此,通过表单提示,我可以从“默认”移动到另一个(例如“所有权”)。
myfile = NamedFile(title=_(u"A file"))
form.fieldset('ownership', fields=['myfile'])
我怎样才能做到这一点?写我自己的行为?
谢谢!
In Archetypes, in order to move a field from a fieldset (or schemata) to another, we can do the following:
schema['creators'].schemata = 'default'
However, I'm not achieving the same using Dexterity. I've tried using form hints. Ex:
form.fieldset('default',
fields=['creators']
)
I notice that it doesn't work because the field "creators" is unknown at this time. (The ownership behavior wasn't evaluated yet).
Nevertheless, with form hints, I can move from "default" to another (eg. "ownership").
myfile = NamedFile(title=_(u"A file"))
form.fieldset('ownership', fields=['myfile'])
How can I do that? Writing my own behavior?
Thx!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您可能需要定义要在您控制的界面上分配的字段。虽然这看起来是重复的,但为了完整和明确的目的,这是一个好主意。您可以:
(1) 在内容类型界面上声明“creators”字段(可能是推荐的解决方案),或者...
(2) 使用此处记录的您自己的行为(并将此行为添加到 Portal_types 中类型的 FTI 中,并且关联的设置 XML): http://docs.plone.org/external/plone.app.dexterity/docs/behaviors/creating-and-registering-behaviors.html
第一个解决方案应该是最简单的。无论如何,您希望控制字段集位置或顺序的任何字段都可能由您的界面定义。
You likely need to make the define the field you want to assign on an interface under your control. While this seems duplicative, it is a good idea for purposes of being complete and explicit. You can either:
(1) Declare 'creators' field on your content type interface (likely, recommended solution), or...
(2) Use your own behavior as documented here (and adding this behavior to the type's FTI in portal_types and associated setup XML): http://docs.plone.org/external/plone.app.dexterity/docs/behaviors/creating-and-registering-behaviors.html
The first solution should be the easiest. Any fields that you wish to control fieldset location or order of should likely be defined by your interfaces anyway.