# Ordering fields in colander based schemas

17 views

### David Bain

Mar 15, 2017, 7:01:30 PM3/15/17
to Kotti
What mechanism do I use to get a newly defined field called "category_type" to show up at the beginning of my form?

I'm working on a schema that looks like this:

`from kotti.views.edit import ContentSchema, DocumentSchema... snip ...class CategorySchema(DocumentSchema):    title = colander.SchemaNode(        colander.String(),        title=_(u'Short Note'),        )    category_type = colander.SchemaNode(        colander.String(),        title=_(u'Question Type'),        validator=colander.OneOf(["radio", "checkbox", "text", "upload"]),        widget=RadioChoiceWidget(values=[            ["radio", _("Single")],            ["checkbox", _("Multiple")],            ["text", _("Paragraph")],            ["upload", _("Upload")]])        )`

The result is a form that has the following structure:

Short Note ____________________
Description ____________________
Tags _________________________
Body __________________________
Category Type
[] Single
[] Multiple
[] Paragraph

I want it to look like this:

Category Type
[] Single
[] Multiple
[] Paragraph
Short Note ____________________
Description ____________________
Tags _________________________
Body __________________________

### David Bain

Mar 15, 2017, 7:10:32 PM3/15/17
to Kotti
To reply to my own question. It turns out that I can get this done easily using "insert_before",

So I just did that:

`    category_type = colander.SchemaNode(        colander.String(),        title=_(u'Question Type'),`
`        insert_before="title",`
`        validator=colander.OneOf(["radio", "checkbox", "text", "upload"]),        widget=RadioChoiceWidget(values=[            ["radio", _("Single")],            ["checkbox", _("Multiple")],            ["text", _("Paragraph")],            ["upload", _("Upload")]])        )`