b4oshany
b4oshany

Reputation: 712

How to re-order colander fields in a form?

I used form inheritance to create a new form, for instance:

class MyForm(ParentForm):
    employment_date = colander.SchemaNode(
        colander.Date(),
        title=_(u'Employment Date')
    )

Lets say the order of the ParentForm fields is

I want the new field, employment_date to be inserted after the email field, i.e.

I want to achieve this without redefining the fields in my schema.

Upvotes: 1

Views: 94

Answers (1)

match
match

Reputation: 11060

You need to use the insert_before argument when adding your schemaNode object (you'll have to reference 'biography' as there is no insert_after argument to use with email):

class MyForm(ParentForm):
    employment_date = colander.SchemaNode(
        colander.Date(),
        title=_(u'Employment Date'),
        insert_before='biography',
    )

Colander schemaNode docs

Upvotes: 2

Related Questions