@view_config(renderer="templates/form.pt", name="select_with_default")
@demonstrate("Select Widget (with default)")
def select_with_default(self):
choices = (
("", "- Select -"),
("habanero", "Habanero"),
("jalapeno", "Jalapeno"),
("chipotle", "Chipotle"),
)
class Schema(colander.Schema):
pepper = colander.SchemaNode(
colander.String(),
default="jalapeno",
widget=deform.widget.SelectWidget(values=choices),
)
schema = Schema()
form = deform.Form(schema, buttons=("submit",))
return self.render_form(form)