Primary and additional schemata in schema forms¶
When using a schema form, it is possible to set two form properties supplying schemata for the form:
- schema is required for all schema forms, and must point to a schema interface. This is known as the default or primary schema for the form.
- additional_schemata is optional, and can be set to a tuple or list of schema interfaces. These will also be included in the form.
Note
If you want to make the schema dynamic, you can implement these as read-only properties. this is how Dexterity’s add and edit forms work, for example - they look up the primary schema from the type information in portal_types, and additional schemata from behaviours.
Later in this manual, we will learn about creating tabbed fieldsets, also known as groups. The schema forms support a property autoGroups which default to False. When set to True, the primary schema will be used as the primary fieldset, and each schema in additional_schemata will become its own fieldset. The schema name will become the fieldset name, and its docstring will become its description. This is obviously somewhat inflexible, but can be useful for certain forms where the fieldsets need to be dynamically looked up.