Moving Dexerity fields to different schema?

We have a Dexterity behavior with lots of fields placed in its own schemata.
We need to place the title + description on top of the same schema instead within the default schemata.

Is there any straight-forward (and clean) way.



It can be done with Diazo:

    <before css:content-children="#fieldset-YOURSCHEMATA">
       <include css:content="#formfield-form-widgets-title" />
       <include css:content="#formfield-form-widgets-description" />

There should be another way, doing it with Diazo doesn't feel right.
IIRC, there is no easy way to move fields between schematas.
But a field from your own schema can be moved to another fieldset with plone.supermodel.model.fieldset. See:
That would mean that you have to make a derivated dublin core behavior with your own title and description...

fieldset() works only for me own schemata but I can not move a different field into my schemata...well...customer needs to click on the default tab...little motivation for making this customer request happen.


Idea (untested and off head):

You may be able to move it by manipulating the tagged values on the behavior directly.

from import IDublinCore
from plone.supermodel.interfaces import FIELDSETS_KEY
from plone.supermodel.model import Fieldset

custom_fieldset = Fieldset(
    label=_(u'My Custom Set'), 
    fields=['title', 'description']
fieldsets = IDublinCore.getTaggedValue(FIELDSETS_KEY)
# TODO: if title and description are in a fieldset you may need to remove them there.
# here I'am not sure if this is needed:
IDublinCore.setTaggedValue(FIELDSETS_KEY, current)

Please tell me if this works.

Poking around to try moving IVersionable.changeNote to another (non-Default) fieldset...

What is current here?

current is not needed. I had the same usecase now and this is how I could solve it (moving changeNote to the settings fieldset):

from import _ as _DX
from import IVersionable
from plone.supermodel.interfaces import FIELDSETS_KEY
from plone.supermodel.model import Fieldset

settings = Fieldset(
fieldsets = IVersionable.getTaggedValue(FIELDSETS_KEY)

This works for me

from plone.dexterity.browser import edit
from plone.z3cform.fieldsets.utils import move

class EditForm(edit.DefaultEditForm):

    def updateFields(self):
        """ Remove field and group from versioningbehavior """
        super(EditForm, self).updateFields()
        move(self, 'IVersionable.changeNote', before='IVersionable.versioning_enabled')

with ZCML of:


You'ld need to repeat it for Add and Display views too of course, but it's clean and it might help some situations.

1 Like