Moving fields between fieldsets on Dexterity

1k views Asked by At

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!

1

There are 1 answers

2
sdupton On BEST ANSWER

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.