I have a form schema which inherits from another form schema. Both have fieldsets. However, the fieldsets are put in the order they are created. So the fieldset described in the last schema will be the last one. I would like it to be the first. Is there a way to do that ?

Example:

from plone.supermodel import model
from zope import schema

class FormSchema(model.Schema):
     model.fieldset(
          'test',
          label='Test',
          fields=['field1']
     )
     field1 = schema.Text(title=u'test')


class FormSchema2(FormSchema):
     # Is last but I would like to place it first
     model.fieldset(
          'test2',
          label='Test2',
          fields=['field2']
     )
     field2 = schema.Text(title=u'test2')
有帮助吗?

解决方案

You can't, I am afraid. The schema fieldsets are always merged in reverse interface resolution order; base before derived interface. Declaring the fieldset again on the FormSchema2 schema will only result in the fieldset being listed twice.

If you have to control fieldset order, don't derive from the base schema but re-declare it.

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top