Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I change fieldsets order?

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')
like image 592
Gagaro Avatar asked Sep 25 '13 08:09

Gagaro


People also ask

What is field set?

A field set is a grouping of fields. For example, you could have a field set that contains fields describing a user's first name, middle name, last name, and business title. When a field set is added to a Visualforce page, developers can loop over its fields and render them.

Does Fieldset have to be in form?

Yes, because the fieldset element is used to group related form fields. Show activity on this post. I used a fieldset outside of a form to group together custom jquery datatable filters.

How do I use Fieldset in Salesforce?

How to create fieldset: The first step for this would be to create the Fieldset. For example, to create field set for Account object, Go to Setup > Customize > Accounts > Field Set. You can now drag and drop all fields you want in this fieldset.


1 Answers

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.

like image 105
Martijn Pieters Avatar answered Nov 12 '22 05:11

Martijn Pieters