Content Type fields define how contributed content will be formatted as it is saved to the dotCMS. There are over 20 different types of fields that can be added to any Content Type.
Content Type Field Parameters
The following table lists all the possible parameters for Content Type Fields, with a brief description of each.
When adding a new field to a Content Type, some parameters are required; fields can not be saved unless all required fields are filled in. Required properties are marked with an asterisk to the left of their labels, as shown in the Example below.
Note: Not all fields have all of these parameters; which parameters a field has and which parameters are required vary depending on the field type.
|Variable/ID||(Read-Only) Displays the field type (only after the Field has been saved the first time).|
|Display Type||Choose how the Field will be edited by content contributors|
(Standard, WYSIWYG, Tag and Category, etc.).
|Label||A label or title for the Field.|
|Data Type||Format of the data to be stored in the Field|
(Text, Decimal, Whole Number, etc.).
|Validation Regex||A regular expression (pre-defined or custom) that limits how data can be entered into the Field.|
(For more information please see the Validation Expressions documentation).
|Code||You must fill out this parameter for some Field types (Radio, Multi-Select, etc.).|
Sample code/instructions are displayed highlighted in yellow to the right of the code field when this is required.
|Default Value||The default value used to automatically populate the Field when a new Content item is added.|
|Hint||Instructions to contributors on how to fill out the Field.|
|Required||Check if the Field is required (e.g. this Field must not be left empty when adding or editing this type of Content).|
|User Searchable||Check to allow users to search the data in the field.|
Fields with this value checked will be individually searchable when searching for content.
If this is checked, the content will automatically be indexed.
|System Indexed||Check to cause the Field to be indexed.|
This improves search performance, but increases the size of the search indexes.
|Show in Listing||Check to allow the Field to display in the search results list when searching for content.|
|Unique||Check to prevent duplicates in the Field.|
This ensures that no two content items have the same value in this Field.
Creating a Multi-Select Field with No Default Value
By default, the first value in a Multi-Select field is the default value (so when new content items are created, the value of the Multi-Select field will be set to the first value listed unless the user manually changes it).
To force a user to manually select a value from the list (instead of using a default value), do both of the following:
- Add only a pipe (“|“) character as the first choice in the select list (do not include a label or value on either side of the pipe character).
- This configures the Field to have no default value (the user must manually select a value, or no value will be saved).
- Check the Required parameter for the Field, so that the default first “null” choice is not valid.
- This forces the content contributor to click and choose an item from the select list before the content item can be saved.
Multi-select fields do NOT need any special handling. Multi-select fields always force the contributor to choose a value, otherwise the field is left blank.
The images below show examples of some of the different field types.
Example 1: Text Field
Example 2: Multi-select Field*