Fields¶
The standard schema fields
The following tables shows the most common field types for use in Dexterity schemata. See the documentation on creating schemata for information about how to use these.
Field properties¶
Fields are initialised with properties passed in their constructors. To avoid having to repeat the available properties for each field, we’ll list them once here, grouped into the interfaces that describe them. You’ll see those interfaces again in the tables below that describe the various field types. Refer to the table below to see what properties a particular interface implies.
Interface |
Property |
Type |
Description |
---|---|---|---|
IField |
title |
unicode |
The title of the field. Used in the widget. |
description |
unicode |
A description for the field. Used in the widget. |
|
required |
bool |
Whether or not the field is required. Used for
form validation. The default is |
|
readonly |
bool |
Whether or not the field is read-only. Default
is |
|
default |
The default value for the field. Used in forms
and sometimes as a fallback value. Must be a
valid value for the field if set. The default
is |
||
missing_value |
A value that represents “this field is not set”.
Used by form validation. Defaults to |
||
IMinMaxLen |
min_length |
int |
The minimum required length or minimum number
of elements. Used for string, sequence, mapping
or set fields. Default is |
max_length |
int |
The maximum allowed length or maximum number
of elements. Used for string, sequence, mapping
or set fields. Default is |
|
IMinMax |
min |
The minimum allowed value. Must be a valid value
for the field, e.g. for an |
|
max |
The maximum allowed value. Must be a valid value
for the field, e.g. for an Int field this should
be an integer. Default is |
||
ICollection |
value_type |
Another |
|
unique |
bool |
Whether or not values in the collection must be
unique. Usually not set directly – use a |
|
IDict |
key_type |
Another |
|
value_type |
Another |
||
IObject |
schema |
Interface |
An interface that must be provided by any object stored in this field. |
IRichText |
default_mime_type |
str |
Default MIME type for the input text of a rich
text field. Defaults to |
output_mime_type |
str |
Default output MIME type for the transformed
value of a rich text field. Defaults to
|
|
allowed_mime_types |
tuple |
A list of allowed input MIME types. The default
is |
Field types¶
The following tables describe the most commonly used field types, grouped by the module from which they can be imported.
Fields in zope.schema¶
Name |
Type |
Description |
Properties |
---|---|---|---|
Choice |
N/A |
Used to model selection from a vocabulary, which must be supplied.
Often used as the |
See vocabularies. |
Bytes |
str |
Used for binary data. |
IField, IMinMaxLen |
ASCII |
str |
ASCII text (multi-line). |
IField, IMinMaxLen |
BytesLine |
str |
A single line of binary data, i.e. a |
IField, IMinMaxLen |
ASCIILine |
str |
A single line of ASCII text. |
IField, IMinMaxLen |
Text |
unicode |
Unicode text (multi-line). Often used with a WYSIWYG widget, although the default is a text area. |
IField, IMinMaxLen |
TextLine |
unicode |
A single line of Unicode text. |
IField, IMinMaxLen |
Bool |
bool |
|
IField |
Int |
int, long |
An integer number. Both ints and longs are allowed. |
IField, IMinMax |
Float |
float |
A floating point number. |
IField, IMinMax |
Tuple |
tuple |
A tuple (non-mutable). |
IField, ICollection, IMinMaxLen |
List |
list |
A list. |
IField, ICollection, IMinMaxLen |
Set |
set |
A set. |
IField, ICollection, IMinMaxLen |
Frozenset |
frozenset |
A frozenset (non-mutable). |
IField, ICollection, IMinMaxLen |
Password |
unicode |
Stores a simple string, but implies a password widget. |
IField, IMinMaxLen |
Dict |
dict |
Stores a dictionary. Both |
IField, IMinMaxLen, IDict |
Datetime |
datetime |
Stores a Python |
IField, IMinMax |
Date |
date |
Stores a python |
IField, IMinMax |
Timedelta |
timedelta |
Stores a python |
IField, IMinMax |
SourceText |
unicode |
A textfield intended to store source text (e.g. HTML or Python code). |
IField, IMinMaxLen |
Object |
N/A |
Stores a Python object that conforms to the interface given as the
|
IField, IObject |
URI |
str |
A URI (URL) string. |
IField, MinMaxLen |
Id |
str |
A unique identifier – either a URI or a dotted name. |
IField, IMinMaxLen |
DottedName |
str |
A dotted name string. |
IField, IMinMaxLen |
InterfaceField |
Interface |
A Zope interface. |
IField |
Decimal |
Decimal |
Stores a Python |
IField, IMinMax |
Fields in plone.namedfile.field
¶
See plone.namedfile and plone.formwidget.namedfile for more details.
Name |
Type |
Description |
Properties |
---|---|---|---|
NamedFile |
NamedFile |
A binary uploaded file. Normally used with the widget from plone.formwidget.namedfile. |
IField |
NamedImage |
NamedImage |
A binary uploaded image. Normally used with the widget from plone.formwidget.namedfile. |
IField |
NamedBlobFile |
NamedBlobFile |
A binary uploaded file stored as a ZODB BLOB. Requires the |
IField |
NamedBlobImage |
NamedBlobImage |
A binary uploaded image stored as a ZODB BLOB. Requires the |
IField |
Fields in z3c.relationfield.schema
¶
See z3c.relationfield for more details.
Name |
Type |
Description |
Properties |
---|---|---|---|
Relation |
RelationValue |
Stores a single |
IField |
RelationList |
list |
A |
See |
RelationChoice |
RelationValue |
A |
See |
Fields in plone.app.textfield¶
See plone.app.textfield for more details.
Name |
Type |
Description |
Properties |
---|---|---|---|
RichText |
RichTextValue |
Stores a |
IField, IRichText |
Fields in plone.schema¶
See plone.schema for more details.
Name |
Type |
Description |
Properties |
---|---|---|---|
str |
A field containing an email address |
IField, IMinMaxLen |