@view_config(
renderer="templates/form.pt",
name="sequence_of_mappings_with_initial_item",
)
@demonstrate("Sequence of Mapping Widgets (with Initial Item)")
def sequence_of_mappings_with_initial_item(self):
class Person(colander.Schema):
name = colander.SchemaNode(colander.String())
age = colander.SchemaNode(
colander.Integer(), validator=colander.Range(0, 200)
)
class People(colander.SequenceSchema):
person = Person()
class Schema(colander.Schema):
people = People()
schema = Schema()
form = deform.Form(schema, buttons=("submit",))
form["people"].widget = deform.widget.SequenceWidget(min_len=1)
return self.render_form(form)