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
This chapter documents common fields, widgets, directives that you can use with content types.
15
-
Content types are often called dexterity types which refers to the rework of the content type concept by dexterity and abandoning the Archetypes system.
15
+
16
+
```{note}
17
+
You might see references to "Dexterity" which is the internal name of Plone's content type system.
18
+
```
16
19
17
20
18
21
## Fields included in Plone
19
22
20
-
This is a schema with examples for all field-types that are shipped with Plone by default. They are arranged in fieldsets:
23
+
This is a schema with examples for all field types that are shipped with Plone by default.
24
+
They are arranged in fieldsets:
21
25
22
-
Text, boolean, email
26
+
Text, Boolean, Email
23
27
24
28
: Textline, RichText, Boolean, Email, URI
25
29
@@ -68,63 +72,8 @@ from zope.interface import implementer
title="RelationChoice – named StaticCatalogVocabulary – Select widget",
@@ -282,16 +251,22 @@ class IExample(model.Schema):
282
251
},
283
252
)
284
253
285
-
# Number fields
286
-
int_field = schema.Int(
287
-
title="Integer Field (e.g. 12)",
288
-
description="zope.schema.Int",
254
+
# File and image fields
255
+
fieldset(
256
+
"filefields",
257
+
label="File",
258
+
fields=("file_field", "image_field"),
259
+
)
260
+
261
+
image_field = NamedBlobImage(
262
+
title="Image field",
263
+
description="A upload field for images (plone.namedfile.field.NamedBlobImage)",
289
264
required=False,
290
265
)
291
266
292
-
float_field = schema.Float(
293
-
title="Float field, e.g. 12.7",
294
-
description="zope.schema.Float",
267
+
file_field = NamedBlobFile(
268
+
title="File field",
269
+
description="A upload field for files (plone.namedfile.field.NamedBlobFile)",
295
270
required=False,
296
271
)
297
272
@@ -588,7 +563,7 @@ directives.widget(
588
563
specialfield = schema.TextLine(title="Field with special frontend widget")
589
564
```
590
565
591
-
Then register your frontend widget in your apps configuration.
566
+
Then register your frontend widget in your Volto configuration.
592
567
593
568
```jsx
594
569
import { MySpecialWidget } from'./components';
@@ -616,7 +591,8 @@ The props will be injected into the corresponding widget component, configuring
616
591
617
592
## Directives
618
593
619
-
Directives can be placed anywhere in the class body (annotations are made directly on the class). By convention they are kept next to the fields they apply to.
594
+
Directives can be placed anywhere in the class body (annotations are made directly on the class).
595
+
By convention, they are kept next to the fields they apply to.
620
596
621
597
For example, here is a schema that omits a field:
622
598
@@ -646,7 +622,8 @@ With the directive "mode" you can set fields to 'input', 'display' or 'hidden'.
646
622
directives.mode(additionalInfo='hidden')
647
623
```
648
624
649
-
You can apply directives to certain forms only. Here we drop a field from the add-form, it will still show up in the edit-form.
625
+
You can apply directives to certain forms only.
626
+
Here we drop a field from the add form, but it will still show up in the edit form.
650
627
651
628
```python
652
629
from z3c.form.interfaces import IAddForm
@@ -664,7 +641,10 @@ class ITask(model.Schema):
664
641
665
642
The same works for custom forms.
666
643
667
-
With the directive {py:meth}`widget` you can not only change the widget used for a field. With {py:data}`pattern_options` you can pass additional parameters to the widget. Here, we configure the datetime widget powered by the JavaScript library [pickadate](https://amsul.ca/pickadate.js/) by adding options that are used by it. Plone passes the options to the library.
644
+
With the directive {py:meth}`widget` you can not only change the widget used for a field.
645
+
With {py:data}`pattern_options` you can pass additional parameters to the widget.
646
+
Here, we configure the datetime widget powered by the JavaScript library [pickadate](https://amsul.ca/pickadate.js/) by adding options that are used by it.
647
+
Plone passes the options to the library.
668
648
669
649
```python
670
650
classIMeeting(model.Schema):
@@ -712,7 +692,8 @@ class IMeeting(model.Schema):
712
692
713
693
Validators and defaults can also be made aware of the context (i.e. to check against the values of other fields).
714
694
715
-
For context aware defaults you need to use a {py:class}`IContextAwareDefaultFactory`. It will be passed the container for which the add form is being displayed:
695
+
For context-aware defaults you need to use a {py:class}`IContextAwareDefaultFactory`.
696
+
It will be passed the container for which the add form is being displayed:
0 commit comments