From 172d5fe4db82c750be9a570a8139123890dd06bf Mon Sep 17 00:00:00 2001 From: Josh Finnie Date: Thu, 16 Feb 2012 00:33:51 -0500 Subject: [PATCH] Document rewrite (Basics Section) As I was going through the documentation, thought this section could use come clarification. --- CONTRIBUTORS.txt | 1 + docs/basics.rst | 20 ++++++++++---------- 2 files changed, 11 insertions(+), 10 deletions(-) diff --git a/CONTRIBUTORS.txt b/CONTRIBUTORS.txt index cf998dc5..838a715a 100644 --- a/CONTRIBUTORS.txt +++ b/CONTRIBUTORS.txt @@ -109,3 +109,4 @@ Contributors - Mathieu Le Marec - Pasquet , 2011/11/08 - Richard Mitchell, 2011/08/11 - Atsushi Odagiri, 2012/02/05 +- Josh Finnie, 2012/02/16 \ No newline at end of file diff --git a/docs/basics.rst b/docs/basics.rst index 51e07576..455e4fc0 100644 --- a/docs/basics.rst +++ b/docs/basics.rst @@ -297,6 +297,14 @@ calling the :meth:`deform.Field.render` method: the :class:`deform.Form` class is a subclass of the :class:`deform.Field` class, so this method is available to a :class:`deform.Form` instance. +If we wanted to render an "add" form (a form without initial +data), we'd just omit the appstruct while calling +:meth:`deform.Field.render`. + +.. code-block:: python + + form = myform.render() + If we have some existing data already that we'd like to edit using the form (the form is an "edit form" as opposed to an "add form"). That data might look like this: @@ -323,7 +331,7 @@ rendering: form = myform.render(appstruct) -If instead we wanted to render a "read-only" variant of an edit form +If, finally, instead we wanted to render a "read-only" variant of an edit form using the same appstruct, we'd pass the ``readonly`` flag as ``True`` to the :meth:`deform.Field.render` method. @@ -334,14 +342,6 @@ to the :meth:`deform.Field.render` method. This would cause a page to be rendered in a crude form without any form controls, so the user it's presented to cannot edit it. -If, finally, we wanted to render an "add" form (a form without initial -data), we'd just omit the appstruct while calling -:meth:`deform.Field.render`. - -.. code-block:: python - - form = myform.render() - Once any of the above statements runs, the ``form`` variable is now a Unicode object containing an HTML rendering of the edit form, useful for serving out to a browser. The root tag of the rendering will be @@ -505,4 +505,4 @@ this chapter, visit The application at http://deformdemo.repoze.org is a :mod:`pyramid` application which demonstrates most of the features of Deform, including most of the widget and data types available for use within -an application that uses Deform. +an application that uses Deform. \ No newline at end of file