Differences between revisions 2 and 3
Revision 2 as of 2009-11-23 04:52:12
Size: 617
Editor: BenGolding
Comment:
Revision 3 as of 2009-11-23 04:56:14
Size: 1032
Editor: BenGolding
Comment:
Deletions are marked like this. Additions are marked like this.
Line 8: Line 8:

    Create the form itself.
Line 9: Line 12:
Line 10: Line 14:

 1. Display the form

    Render the form to the web page, typically using {{{<alx-form name="model_form" errors>}}} in your Albatross template for the page.
Line 11: Line 20:

    Check that the data that the user entered is correct. The call to {{{validate}}} will raise a {{{FormValidationError}}} exception.
Line 12: Line 24:
         Update the model with the data fields collected from the form.

Flow of Control

The flow of control through Albatross forms is tied in with Albatross's flow of control.

A mistake I have made a couple of times is to reinitialise the form from the model part way through the user's interaction with the page (ie, before they've saved it). It winds up losing any changes that the user has made on the form. The lesson here is that the form should only be loaded from the model once when the user starts interacting with it; don't reload it on each page refresh.

  1. Constructor
    • Create the form itself.
  2. Load from model
    • I normally do this in the constructor.
  3. Display the form
    • Render the form to the web page, typically using <alx-form name="model_form" errors> in your Albatross template for the page.

  4. Validate
    • Check that the data that the user entered is correct. The call to validate will raise a FormValidationError exception.

  5. Merge
    • Update the model with the data fields collected from the form.

None: Flow_of_control (last edited 2011-02-15 06:05:17 by localhost)