在敏捷之间的字段集之间移动字段 [英] Moving fields between fieldsets on Dexterity

查看:100
本文介绍了在敏捷之间的字段集之间移动字段的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在原型中,为了将一个字段从一个字段集(或模式)移动到另一个字段,我们可以执行以下操作:

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']
 )

我注意到它不起作用,因为此时"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?

谢谢!

推荐答案

您可能需要在要控制的接口上定义要分配的字段.尽管这似乎是重复的,但出于完整和明确的目的,这是一个好主意.您可以:

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)在内容类型界面上声明创建者"字段(可能是推荐的解决方案),或者...

(1) Declare 'creators' field on your content type interface (likely, recommended solution), or...

(2)使用此处记录的自己的行为(并将此行为添加到portal_types和关联的设置XML中的类型的FTI中):

(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.

这篇关于在敏捷之间的字段集之间移动字段的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆