4

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!

Thiago Curvelo
  • 3,711
  • 1
  • 22
  • 38

1 Answers1

3

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.

Danimal
  • 1,208
  • 10
  • 21
sdupton
  • 1,869
  • 10
  • 9
  • 1
    By following (1), I must do something like `creators = schema.Text()`, at the schema interface, right? I did that, but the `creators` from `IOwnership` didn't overlap the one I declared. Do u have an example? – Thiago Curvelo Jan 18 '12 at 15:30
  • 1
    Yes, create a 'creators' schema field on your interface, and subclass the IOwnership interface instead of mixing into the FTI as a behavior. It is likely that the behavior is composed into the plone.autoform groups for the edit form without considering your choice. If you absolutely must use a behavior, choose route #2 above. – sdupton Jan 18 '12 at 19:10