Move fields between fields on Dexterity

In Archetypes, to move a field from a set of fields (or schemas) to another, we can do the following:

schema['creators'].schemata = 'default' 

However, I do not achieve the same using Dexterity. I tried using form hints. Example:

 form.fieldset('default', fields=['creators'] ) 

I notice that this does not work, because the "creators" field is unknown at this time. (Ownership has not yet been evaluated).

However, with the prompts in the form, I can go from "default" to another (for example, "property").

 myfile = NamedFile(title=_(u"A file")) form.fieldset('ownership', fields=['myfile']) 

How can i do this? Writing your own behavior?

thanks!

+4
source share
1 answer

You probably need to define the field that you want to assign to the interface you control. Although this seems duplicate, it is a good idea for complete and explicit purposes. You can:

(1) Declare the "creators" field on your interface as a content type (probably the recommended solution) or ...

(2) Use your own behavior as described here (and add this behavior to the FTI type in portal_types and the corresponding XML installation): http://docs.plone.org/external/plone.app.dexterity/docs/behaviors/ creating-and-registering-behaviors.html

The first solution should be the simplest. Any fields that you want to control the location or order of fields should probably be defined by your interfaces.

+3
source

Source: https://habr.com/ru/post/1258361/


All Articles