简体   繁体   中英

Moving fields between fieldsets on Dexterity

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!

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM