@view_config(renderer="templates/form.pt", name="sequence_of_sequences")
@demonstrate("Sequence of Sequence Widgets")
def sequence_of_sequences(self):
class NameAndTitle(colander.Schema):
name = colander.SchemaNode(colander.String())
title = colander.SchemaNode(colander.String())
class NamesAndTitles(colander.SequenceSchema):
name_and_title = NameAndTitle(title="Name and Title")
class NamesAndTitlesSequences(colander.SequenceSchema):
names_and_titles = NamesAndTitles(title="Names and Titles")
class Schema(colander.Schema):
names_and_titles_sequence = NamesAndTitlesSequences(
title="Sequence of Sequences of Names and Titles"
)
schema = Schema()
form = deform.Form(schema, buttons=("submit",))
outer = form["names_and_titles_sequence"]
outer.widget = deform.widget.SequenceWidget(min_len=1)
outer["names_and_titles"].widget = deform.widget.SequenceWidget(
min_len=1
)
return self.render_form(form)