@view_config(renderer="templates/form.pt", name="checkboxchoice2")
@demonstrate("Checkbox Choice Widget (with required field)")
def checkboxchoice2(self):
choices = (
("habanero", "Habanero"),
("jalapeno", "Jalapeno"),
("chipotle", "Chipotle"),
)
@colander.deferred
def deferred_checkbox_widget(node, kw):
return deform.widget.CheckboxChoiceWidget(values=choices)
class Schema(colander.Schema):
pepper = colander.SchemaNode(
colander.Set(), widget=deferred_checkbox_widget
)
required = colander.SchemaNode(colander.String())
schema = Schema()
schema = schema.bind()
form = deform.Form(schema, buttons=("submit",))
return self.render_form(form)