From ee746488515885354f45a6efd36ce58359afba3e Mon Sep 17 00:00:00 2001 From: Doug Hellmann Date: Fri, 3 May 2013 09:34:36 -0400 Subject: Clean up and update docs Clean up some formatting issues in doc sources and smooth out some wording. Change-Id: I2bb2c9a32d67b71deeb7fcc13fd6a2949b4e195b Signed-off-by: Doug Hellmann --- docs/source/forms.rst | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) (limited to 'docs/source/forms.rst') diff --git a/docs/source/forms.rst b/docs/source/forms.rst index 91c3f06..7f7e2da 100644 --- a/docs/source/forms.rst +++ b/docs/source/forms.rst @@ -2,7 +2,8 @@ Generating and Validating Forms =============================== -Out of the box, Pecan provides no opinionated support for working with + +Pecan provides no opinionated support for working with form generation and validation libraries, but it’s easy to import your library of choice with minimal effort. @@ -12,7 +13,10 @@ This article details best practices for integrating the popular forms library, Defining a Form Definition -------------------------- -Let's start by building a basic form with a required ``first_name`` field and an optional ``last_name`` field:: +Let's start by building a basic form with a required ``first_name`` +field and an optional ``last_name`` field. + +:: from wtforms import Form, TextField, validators @@ -26,7 +30,9 @@ Let's start by building a basic form with a required ``first_name`` field and an Rendering a Form in a Template ------------------------------ -Next, let's add a controller, and pass a form instance to the template:: +Next, let's add a controller, and pass a form instance to the template. + +:: from pecan import expose from wtforms import Form, TextField, validators @@ -41,8 +47,9 @@ Next, let's add a controller, and pass a form instance to the template:: def index(self): return dict(form=MyForm()) -Here's the template file (which uses the `Mako `_ -templating language): +Here's the Mako_ template file: + +.. _Mako: http://www.makeotemplates.org/ .. code-block:: html @@ -61,7 +68,7 @@ templating language): Validating POST Values ---------------------- -Using the same ``MyForm`` definition, let's redirect the user if the form is +Using the same :class:`MyForm` definition, let's redirect the user if the form is validated, otherwise, render the form again. .. code-block:: python -- cgit v1.2.1