# wt.multiform module

## Synopsis

The `wt.multiform` module provides a `TemplateCode` sub-class which helps with creating multiple-page input forms ("multiforms"). Pages with errors are redisplayed so that the user can correct the errors, and all the input from the different pages is collected together into one mapping.

## Usage

## class: MultiForm(TemplateCode)

### Public Class Variables

#### `name`

This variable may be overridden by subclasses. It specifies the name of the key in the current `Session` object which will be used to store the input container. The name is prepended with `multiform_` before being used. The default value is `standard`. If this variable is set to `None` then no session is required and hidden form fields are used to store input values instead - see `Stage.form` for details.

#### `stages`

This variable must be overridden by subclasses. It specifies how many stages make up the current multiform.

#### `keys`

This variable may be overridden by subclasses. It specifies container keys that are not associated with any individual stage - for example, container keys that are initialised by form variables passed in to the start of the multiform.

#### `filename`

This variable must be overridden by subclasses. It specifies the filename relative to the template file directory of the stage templates. The filename should contain the sequence `%d`, which will be replaced by the stage number required. If a literal `%` is required in the filename, `%%` should be used.

#### `stagen`

Subclasses of `MultiForm` should provide subclasses of `Stage` named `stage0`, `stage1`, `stage2` etc, which provide the code for the pages for the 1st, 2nd, 3rd, etc stages respectively.

### Public Instance Variables

#### `container`

A dictionary which contains the input values for the multiform.

#### `stage`

The current stage number.

#### `errors`

A list containing the current input validation errors. If there are no errors then the list is empty.

### Public Methods

#### `init(self)`

This method may be overridden by subclasses. It is called when a new multiform is started. It should set up initial values in `self.container` for all inputs, even those whose default value should be the empty string. The default implementation does nothing.

#### `update(self)`

This method may be overridden by subclasses. It is called on every stage just before the individual stages' `update` methods are called. It can perform any global updating that may be necessary.

#### `check(self)`

This method may be overridden by subclasses. It is called on every stage just before the individual stages' `check` methods are called. It can perform any global checking that may be necessary, and update `self.errors` as it sees fit. Note that it is up to this method to alter `self.stage` manually if required.

#### `delete(self)`

If this multiform's input container is being stored in a session, deletes the relevant session key. Otherwise, does nothing.

#### `main(self, template)`

`template`: string

## class: Stage(TemplateCode)

### Public Class Variables

#### `keys`

### Public Methods

#### `form(self)`

#### `update(self)`

#### `check(self)`

$Id: wt-multiform.html,v 1.2 2002/05/01 01:17:24 jribbens Exp $