plone.autoform (1.0)
- Homepage of plone.autoform: http://pypi.python.org/pypi/plone.autoform
The tagged values are stored under a various keys. These can be found in the plone.autoform.interfaces module. They support:
- changing a field to 'display' or 'hidden' mode
- omitting fields
- re-ordering fields relative to one another
- placing fields into fieldsets (groups)
- changing the widget of a field
- displaying a field conditionally based on a permission
There are several ways to set the form data:
- Manually, by using setTaggedValue() on an interface.
- By loading the schema from a plone.supermodel XML file and using the form: prefix
- By using the grok directives in the plone.directives.form package.
To use the automatic form setup, mix in the following base class in your forms:
>>> from plone.autoform.form import AutoExtensibleForm
and then provide the 'schema' (a schema interface) and optionally the 'additionalSchemata' (a list of schema interfaces) attributes on your form:
>>> class MyForm(AutoExtensibleForm, form.EditForm):
... schema = IMySchema
... additionalSchemata = (ISchemaOne, ISchemaTwo,)
...
... # ...
For dynamic forms, you could of course make 'schema' and 'additionalSchemata' into properties.
To use the display form, create a view like:
>>> from plone.autoform.view import WidgetsView
>>> class MyView(WidgetsView):
... schema = IMySchema
... additionalSchemata = (ISchemaOne, ISchemaTwo,)
...
... #
To render the form, do not override __call__(). Instead, either implement the render() method or set an 'index' attribute to a page template or other callable.
See autoform.txt for details on how to use the form generation, view.txt for details on the widgets view, and supermodel.txt for information on the 'form' XML namespace in a plone.supermodel schema file.