You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Sometimes rather than rendering a form for data entry, you want to display stored values based on the same schema.
150
144
This can be done using a "display form".
151
-
The display form renders each field's widget in "display mode" which means that it shows the field value in read-only form rather than as a form input.
145
+
The display form renders each field's widget in "display mode", which means that it shows the field value in read-only form rather than as a form input.
152
146
153
147
To use the display form, create a view that extends `WidgetsView` like this:
154
148
@@ -158,17 +152,19 @@ from plone.autoform.view import WidgetsView
158
152
classMyView(WidgetsView):
159
153
schema = IMySchema
160
154
additionalSchemata = (ISchemaOne, ISchemaTwo,)
161
-
162
-
# ...
163
155
```
164
156
165
157
To render the form, do not override `__call__()`.
166
158
Instead, either implement the `render()` method, set an `index` attribute to a page template or other callable, or use the `template` attribute of the `<browser:page />` ZCML directive when registering the view.
167
159
168
160
In the template, you can use the following variables:
169
161
170
-
-`view/w` is a dictionary of all widgets, including those from non-default fieldsets (by contrast, the `widgets` variable contains only those widgets in the default fieldset). The keys are the field names, and the values are widget instances. To render a widget (in display mode), you can do `tal:replace="structure view/w/myfield/render" />`.
171
-
-`view/fieldsets` is a dictionary of all fieldsets (not including the default fieldset, in other words, those widgets not placed into a fieldset. The keys are the fieldset names, and the values are the fieldset form instances, which in turn have variables like `widgets` given a list of all widgets.
162
+
-`view/w` is a dictionary of all widgets, including those from non-default fieldsets.
163
+
By contrast, the `widgets` variable contains only those widgets in the default fieldset.
164
+
The keys are the field names, and the values are widget instances.
165
+
To render a widget (in display mode), you can do `tal:replace="structure view/w/myfield/render" />`.
166
+
-`view/fieldsets` is a dictionary of all fieldsets not including the default fieldset, in other words, those widgets not placed into a fieldset.
167
+
The keys are the fieldset names, and the values are the fieldset form instances, which in turn have variables, such as `widgets`, given a list of all widgets.
0 commit comments