Skip to content

Commit 15bc6bd

Browse files
committed
improve schemas, fields and widgets chapters
1 parent e888ed8 commit 15bc6bd

File tree

3 files changed

+26
-11
lines changed

3 files changed

+26
-11
lines changed

docs/backend/fields.md

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -11,11 +11,14 @@ myst:
1111

1212
# Fields
1313

14-
This chapter describes the standard schema fields in Plone content types.
14+
This chapter describes the standard schema fields for Plone forms and content types.
1515

16-
The following tables show the most common field types for use in Dexterity schemata.
17-
See the documentation on {ref}`creating schemata <backend-schemas-label>` for information about how to use these.
16+
The following tables show the most common field types for use in {ref}`classic-ui-forms-label` and Dexterity {ref}`backend-content-types-label`.
17+
See {ref}`schemas <backend-schemas-label>` for information about how fields compose a schema for a form or content type data model.
1818

19+
```{note}
20+
In VS Code editor, you can install the [Plone Snippets](https://marketplace.visualstudio.com/items?itemName=Derico.plone-vs-snippets) extension. This will give you snippets for most fields, widgets and autoform directives in Python and XML based schemas.
21+
```
1922

2023
## Field properties
2124

@@ -36,7 +39,7 @@ Refer to the table below to see what properties a particular interface implies.
3639
| | `max_length `| int | The maximum allowed length or maximum number of elements. Used for `string`, sequence, mapping, or `set` fields. Default is `None` (no check). |
3740
| `IMinMax` | `min` | | The minimum allowed value. Must be a valid value for the field, for example, an int field should be an integer. Default is `None` (no check). |
3841
| | `max` | | The maximum allowed value. Must be a valid value for the field, for example an int field should be an integer. Default is `None` (no check). |
39-
| `ICollection` | `value_type` | | Another `Field` instance that describes the allowable values in a list, tuple, or other collection. Must be set for any collection field. One common usage is to set this to a `Choice` to model a multi-selection field with a vocabulary. |
42+
| `ICollection` | `value_type` | | Another `Field` instance that describes the allowable values in a list, tuple, or other collection. Must be set for any collection field. One common usage is to set this to a `Choice` to model a multi-selection field with a {ref}`vocabulary <backend-vocabularies-label>`. |
4043
| | `unique` | bool | Whether or not values in the collection must be unique. Usually not set directly. Use a `Set` or `Frozenset` to guarantee uniqueness in an efficient way. |
4144
| `IDict` | `key_type` | | Another `Field` instance that describes the allowable keys in a dictionary. Similar to the `value_type` of a collection. Must be set. |
4245
| | `value_type` | | Another `Field` instance that describes the allowable values in a dictionary. Similar to the `value_type` of a collection. Must be set. |
@@ -55,7 +58,7 @@ The following tables describe the most commonly used field types, grouped by the
5558

5659
| Name | Type | Description | Properties |
5760
| - | - | - | - |
58-
| Choice | N/A | Used to model selection from a vocabulary, which must be supplied. Often used as the `value_type` of a selection field. The value type is the value of the terms in the vocabulary. | See {doc}`../advanced/vocabularies`. |
61+
| Choice | N/A | Used to model selection from a vocabulary, which must be supplied. Often used as the `value_type` of a selection field. The value type is the value of the terms in the vocabulary. | See {ref}`backend-vocabularies-label`. |
5962
| Bytes | str | Used for binary data. | IField, IMinMaxLen |
6063
| ASCII | str | ASCII text (multi-line). | IField, IMinMaxLen |
6164
| BytesLine | str | A single line of binary data, in other words a `Bytes` with new lines disallowed. | IField, IMinMaxLen |
@@ -117,11 +120,12 @@ See [`plone.app.textfield`](https://pypi.org/project/plone.app.textfield/) for m
117120

118121
### Fields in `plone.schema`
119122

120-
See [`plone.schema`](https://pypi.org/project/plone.schema/) for more details.
123+
See {ref}`backend-ploneschema-label` for more details.
121124

122125
| Name | Type | Description | Properties |
123126
| ----- | ---- | ----------------------------------- | ------------------ |
124-
| Email | str | A field containing an email address | IField, IMinMaxLen |
127+
| Email | str | A field containing an email address | IField, IMinMaxLen |
128+
| JSON | | | |
125129

126130

127131
(backend-fields-schema-label)=

docs/backend/schemas.md

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,9 +46,12 @@ Zope schemas are used for tasks like:
4646
The basic unit of data model declaration is the {ref}`field <backend-fields-label>`, which specifies what
4747
kind of data each Python attribute can hold.
4848

49-
### zope.schema / plone.schema
5049

51-
The main package is [zope.schema](http://github.com/zopefoundation/zope.schema), but in we can also use [plone.schema](https://github.com/plone/plone.schema) which provides additional fields and widgets for z3c.form and optional integration with Plone.
50+
(backend-ploneschema-label)=
51+
52+
### plone.schema vs zope.schema
53+
54+
The main package is [zope.schema](http://github.com/zopefoundation/zope.schema), but we can also use [plone.schema](https://github.com/plone/plone.schema) which provides additional fields and widgets for z3c.form and optional integration with Plone.
5255

5356
Additional features are:
5457

@@ -62,6 +65,10 @@ Additional features are:
6265

6366
### Example of a schema
6467

68+
```{note}
69+
In VS Code editor, you can install the [Plone Snippets](https://marketplace.visualstudio.com/items?itemName=Derico.plone-vs-snippets) extension. This will give you snippets for most fields, widgets and autoform directives in Python and XML based schemas.
70+
```
71+
6572
Define a schema for a data model to store addresses:
6673

6774
```

docs/backend/widgets.md

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,10 @@ When an HTTP `post` request comes in, Zope publisher automatically converts `<se
3030

3131
## Widget reference
3232

33+
```{note}
34+
In VS Code editor, you can install the [Plone Snippets](https://marketplace.visualstudio.com/items?itemName=Derico.plone-vs-snippets) extension. This will give you snippets for most fields, widgets and autoform directives in Python and XML based schemas.
35+
```
36+
3337
You can find the default widgets in the browser package in `z3c.form`.
3438
The [`z3c.form` documentation](https://z3cform.readthedocs.io/en/latest/widgets/index.html) lists all the default widgets and shows the HTML output of each.
3539

@@ -287,7 +291,7 @@ class IFlexibleContent(form.Schema):
287291
# Hide widget "sections"
288292
form.mode(sections="hidden")
289293

290-
# set mode
294+
# set mode
291295
form.mode(IEditForm, sections="input")
292296
form.mode(IAddForm, sections="input")
293297

@@ -601,7 +605,7 @@ Then you set the `my_combined_field` widget template in `updateWidgets()`:
601605
class MyForm(form.Form):
602606
603607
fields = field.Fields(IMyFormSchema)
604-
608+
605609
def updateWidgets(self, prefix=None):
606610
"""
607611
"""

0 commit comments

Comments
 (0)