@view_config(renderer="templates/form.pt", name="selectize_with_multiple")
@demonstrate("Selectize Widget (with multiple)")
def selectize_with_multiple(self):
choices = (
("habanero", "Habanero"),
("jalapeno", "Jalapeno"),
("chipotle", "Chipotle"),
)
class Schema(colander.Schema):
pepper = colander.SchemaNode(
colander.Set(),
widget=deform.widget.SelectizeWidget(
values=choices,
multiple=True,
attributes={
"placeholder": "Select...",
},
),
validator=colander.Length(
min=1, min_err="You must select at least one pepper."
),
)
schema = Schema()
form = deform.Form(schema, buttons=("submit",))
return self.render_form(form)