@view_config(renderer="templates/form.pt", name="ajaxform")
@demonstrate("AJAX form submission (inline success)")
def ajaxform(self):
class Mapping(colander.Schema):
name = colander.SchemaNode(
colander.String(), description="Content name"
)
date = colander.SchemaNode(
colander.Date(),
widget=deform.widget.DatePartsWidget(),
description="Content date",
)
class Schema(colander.Schema):
number = colander.SchemaNode(colander.Integer())
mapping = Mapping()
richtext = colander.SchemaNode(
colander.String(), widget=deform.widget.RichTextWidget()
)
schema = Schema()
form = deform.Form(schema, buttons=("submit",), use_ajax=True)
def succeed():
return Response('<div id="thanks">Thanks!</div>')
return self.render_form(form, success=succeed)