How to reorder fields?

I have a form schema that inherits from another form. Both have fieldsets . However, field sets are placed in the order in which they are created. Thus, the field string described in the last diagram will be the last. I would like this to be the first. Is there any way to do this?

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') 
+6
source share
1 answer

You cannot, I'm afraid. Schema field sets are always combined in the order of resolution of the reverse interface; base to the derived interface. Declaring a field again in the FormSchema2 will only result in a list of fields being twice specified.

If you need to control the order of overlapping fields, do not leave the base schema, but re-declare it.

+2
source

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


All Articles