A more complex example
Here is a rather more complex example that uses a number of different input types.
Here's the model.
The form that describes how we want it laid out
1 # Slightly abridged list of all the countries in the world.
2 country_names = (
3 'Australia',
4 'Belgium',
5 'Cuba',
6 'Greenland',
7 'Madagascar',
8 'Netherlands',
9 'Switzerland',
10 'Uzbekistan',
11 'Zimbabwe'
12 )
13 country_menu = [e for e in enumerate(country_names)]
14 fields = (
15 TextField('Name', 'name', required=True),
16 IntegerField('Integer', 'an_int'),
17 FloatField('Float', 'a_float'),
18 SelectField('Country', country_menu, 'country'),
19 PasswordField('Password', 'password',
20 required=True),
21 Checkbox('Active', 'active'),)
22 buttons = Buttons((
23 Button('save', 'Save'),
24 Button('cancel', 'Cancel'),
25 ))
26 elements = (Fieldset(fields),)
27 ctx.locals.test_form = FieldsetForm('User details',
28 elements,
29 buttons=buttons)
Render the form on the page:
That looks like this: attachment:forms-complex-1.png
To render the form as static report: