diff options
author | Ryan Petrello <lists@ryanpetrello.com> | 2013-05-06 08:48:16 -0700 |
---|---|---|
committer | Ryan Petrello <lists@ryanpetrello.com> | 2013-05-06 08:48:16 -0700 |
commit | 57d1073ac4492bc21fe414ef5f9bd51670d5910a (patch) | |
tree | 77240434ae16b0bbf4734fabd75f549fbb0eb15c /docs/source/forms.rst | |
parent | 98f3c566ee3eb7f9d3b31e9e153dc8cbf3e22dc4 (diff) | |
parent | 649af77ec0c39ac11c9ae9e66934b449fc59e60c (diff) | |
download | pecan-57d1073ac4492bc21fe414ef5f9bd51670d5910a.tar.gz |
Merge pull request #213 from dhellmann/doc-cleanup
Clean up and update docs
Diffstat (limited to 'docs/source/forms.rst')
-rw-r--r-- | docs/source/forms.rst | 19 |
1 files changed, 13 insertions, 6 deletions
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 <http://www.makeotemplates.org/>`_ -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 |