@view_config(
renderer="templates/form.pt", name="multiple_error_messages_seq"
)
@demonstrate("Multiple Error Messages For a Single Widget (Sequence)")
def multiple_error_messages_seq(self):
def v1(node, value):
msg = _("Error ${num}", mapping=dict(num=1))
raise colander.Invalid(node, msg)
def v2(node, value):
msg = _("Error ${num}", mapping=dict(num=2))
raise colander.Invalid(node, msg)
def v3(node, value):
msg = _("Error ${num}", mapping=dict(num=3))
raise colander.Invalid(node, msg)
class Sequence(colander.SequenceSchema):
field = colander.SchemaNode(
colander.String(),
title="Fill in a value and submit to see multiple errors",
validator=colander.All(v1, v2, v3),
)
class Schema(colander.Schema):
fields = Sequence()
schema = Schema()
form = deform.Form(schema, buttons=("submit",))
return self.render_form(form)