1

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

  • name
  • email
  • biography

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

  • name
  • email
  • employment_date
  • biography

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

pault
  • 41,343
  • 15
  • 107
  • 149
b4oshany
  • 692
  • 1
  • 7
  • 15

1 Answers1

2

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

match
  • 10,388
  • 3
  • 23
  • 41