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
Copy file name to clipboardExpand all lines: docs/classic-ui/forms.md
+35-31Lines changed: 35 additions & 31 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,41 +1,43 @@
1
1
---
2
2
myst:
3
3
html_meta:
4
-
"description": ""
5
-
"property=og:description": ""
6
-
"property=og:title": ""
7
-
"keywords": ""
4
+
"description": "Create forms in Plone"
5
+
"property=og:description": "Create forms in Plone"
6
+
"property=og:title": "Create forms in Plone"
7
+
"keywords": "Plone, forms"
8
8
---
9
9
10
10
(classic-ui-forms-label)=
11
11
12
12
# Forms
13
13
14
14
```{todo}
15
-
Describe how create forms with Plone's default form framework z3c.form.
16
-
Fields, Widgets, Vocabularies aso are descripted in detail in there own chapter and will be referenced from examples here.
15
+
Describe how create forms with Plone's default form framework `z3c.form`.
16
+
{doc}`/backend/fields`, {doc}`/backend/widgets`, {doc}`/backend/vocabularies` are also described in detail in their own chapters, and will be referenced from examples here.
17
17
```
18
18
19
-
Plone uses the [z3c.form](http://pythonhosted.org/z3c.form) library to build its web-forms.
20
-
The packages responsible for integrating with Plone are [plone.z3cform](https://github.com/plone//plone.z3cform) and [plone.app.z3cform](https://github.com/plone/plone.app.z3cform) which contains most of the widgets and default templates. To simplify the process of organizing a form and specifying its widgets and fields, Plone utilizes [plone.autoform](https://github.com/plone/plone.autoform), in particular its `AutoExtensibleForm` base class. It is responsible for handling form hints and configuring z3c.form widgets and groups (fieldsets).
21
-
22
-
A form is a view that utilizes these libraries to auto generate forms.
19
+
Plone uses the [`z3c.form`](https://z3cform.readthedocs.io/en/latest/) library to build its webforms.
20
+
The packages responsible for integrating `z3c.form`with Plone are [`plone.z3cform`](https://github.com/plone/plone.z3cform) and [`plone.app.z3cform`](https://github.com/plone/plone.app.z3cform), which contain most of the widgets and default templates.
21
+
To simplify the process of organizing a form and specifying its widgets and fields, Plone utilizes [`plone.autoform`](https://github.com/plone/plone.autoform), in particular its `AutoExtensibleForm` base class.
22
+
It is responsible for handling form hints and configuring `z3c.form` widgets and groups (fieldsets).
23
23
24
+
A form is a view that uses these libraries to generate forms.
24
25
25
26
26
27
(classic-ui-forms-general-forms-label)=
28
+
27
29
## General forms
28
30
29
31
The {term}`plonecli` provides you with an option to add a form to your Plone package.
30
-
Given you have created an addon package with {term}`plonecli` called `collective.awesomeaddon`.
32
+
Let's assume you created an add-on package with {term}`plonecli` called `collective.awesomeaddon`.
31
33
32
34
```shell
33
35
cd collective.awesomeaddon
34
36
plonecli add form
35
37
```
36
38
37
39
After using the {term}`plonecli` to add a form, you'll have a new sub folder `forms` in your package.
38
-
Here you will find a `configure.zcml` containing the registration of the form,
40
+
Here you will find a `configure.zcml` containing the registration of the form.
39
41
40
42
```xml
41
43
<!-- ZCML header and other ZCML here -->
@@ -49,7 +51,7 @@ Here you will find a `configure.zcml` containing the registration of the form,
49
51
/>
50
52
```
51
53
52
-
and a Python file with the code.
54
+
And a Python file with the code.
53
55
54
56
```python
55
57
from plone import schema
@@ -91,37 +93,41 @@ class MyForm(AutoExtensibleForm, form.EditForm):
91
93
92
94
@button.buttonAndHandler("Cancel")
93
95
defhandleCancel(self, action):
94
-
"""User canceled. Redirect back to the front page.
96
+
"""User cancelled. Redirect back to the front page.
95
97
"""
96
-
97
98
```
98
99
99
-
Our form `MyForm` is a sub class of the z3c.form base class `z3c.form.form.EditForm` and `plone.autoform.form.AutoExtensibleForm` which add some convenient methods to organize the form fields and widgets.
100
-
Besides some basic properties like `label` and `description`, the more interesting properties are `schema` and `ignoreContext`.
100
+
Our form `MyForm` is a subclass of the `z3c.form` base class, `z3c.form.form.EditForm`, and `plone.autoform.form.AutoExtensibleForm`, which adds some convenient methods to organize the form fields and widgets.
101
+
Besides some basic properties such as `label` and `description`, the more interesting properties are `schema` and `ignoreContext`.
102
+
103
+
104
+
### Configure the form
105
+
106
+
In this section, you will configure the form's properties.
101
107
102
-
### configuring the form
103
108
104
-
#### schema
109
+
#### `schema`
105
110
106
111
The schema property points to a schema interface, which defines the fields of our form.
107
112
108
-
```
113
+
```python
109
114
schema = IMyForm
110
115
```
111
116
112
-
### ignoreContext
113
117
114
-
If your form is not bound to an object (like a Dexterity object), set `ignoreContext = True`.
118
+
#### `ignoreContext`
119
+
120
+
If your form is not bound to an object (such as a Dexterity object), set `ignoreContext = True`.
Dexterity content types are coming with default add and edit forms.
121
-
You can build custom add and edit forms to adjust there behavior.
125
+
## Dexterity add and edit forms
122
126
123
-
The implementation of the default edit and add forms is in [plone.dexterity.browser.edit.py](https://github.com/plone/plone.dexterity/blob/master/plone/dexterity/browser/edit.py) and [plone.dexterity.browser.add.py](https://github.com/plone/plone.dexterity/blob/master/plone/dexterity/browser/add.py).
127
+
Dexterity content types come with default add and edit forms.
128
+
You can build custom add and edit forms to adjust their behavior.
124
129
130
+
The implementation of the default edit and add forms is in [`plone.dexterity.browser.edit.py`](https://github.com/plone/plone.dexterity/blob/master/plone/dexterity/browser/edit.py) and [`plone.dexterity.browser.add.py`](https://github.com/plone/plone.dexterity/blob/master/plone/dexterity/browser/add.py).
125
131
126
132
```{todo}
127
133
Describe Add/Edit forms here and how to customize them.
@@ -131,7 +137,7 @@ Provide mutiple examples.
131
137
132
138
### Disable form tabbing
133
139
134
-
To disable the form tabbing, you have to override the edit and add forms and provide a property enable_form_tabbing which is False.
140
+
To disable the form tabbing, you have to override the edit and add forms, and provide a property `enable_form_tabbing` as `False`.
135
141
136
142
The Python code `custom_forms.py` should look like this:
137
143
@@ -172,11 +178,10 @@ class ICustomAddView(Interface):
172
178
@implementer(ICustomAddView)
173
179
classCustomAddView(add.DefaultAddView):
174
180
form = CustomAddForm
175
-
176
181
```
177
182
178
-
to activate them, you have to override the registration of the forms for your desired content types.
179
-
In your configure.zcml:
183
+
To activate them, you must override the registration of the forms for your desired content types.
0 commit comments