0

I have created 2 colander schemas as these reflect my database structure. I want to present both forms on one page with one submit button instead of two so that when submit is pressed it will validate and return errors for both forms at the same time.

I have tried putting submit on only one of the form variables but when submit is pressed only that particular form is validated. Is there a way to have the 'submit' button separate from the deform form structure?


import colander

# create colander schemas 

class Person(colander.MappingSchema):
    name = colander.SchemaNode(colander.String())
    age = colander.SchemaNode(colander.Integer(),
                              validator=colander.Range(0, 200))

class People(colander.SequenceSchema):
    person = Person()

class Schema(colander.MappingSchema):
    people = People()


class Sample(colander.MappingSchema):
    sample_ID = colander.SchemaNode(colander.String())
    samplename = colander.SchemaNode(colander.Integer(),
                              validator=colander.Range(0, 200))


schema = Schema()
secondschema = Sample()

#create forms using deform

from deform import Form
myform = Form(schema, buttons=('submit',))
secondform = Form(secondschema, buttons=('submit'),)) ```
  • Why would you not combine the two schema, e.g., `class Parent(colander.Schema): people = People(), sample = Sample()`? – Steve Piercy Jun 17 '19 at 10:25
  • Thank you this worked! Although the only thing I would say is for some reason it didn't work with the comma in between the two. If I put the comma it only rendered the second form. – Sarach Griffin Jun 19 '19 at 09:46

0 Answers0