Page History
...
clear | both |
---|---|
align | right |
class | menu |
This page describes two ways in which you may define the type of a field in a form .
Table of Contents |
---|
When creating a form tab in a dialogfor a dialog's tab, you usually want it to contain some fields. The fields are the core building blocks of the form's functionality for user tasks such as entering a text in a form and sending it to the a server after hitting the the user hits the form's submit button. Any field like that must be defined in a dialog definition through
Fields are defined using a field definition, which must contain – at minimum – a property telling Magnolia what type of field it should render in the dialog.
...
Until the release of Magnolia 5.7, the only way to specify the type of a field was to state its fully qualified class name. For example, to create a simple text field named title
in a dialog's tab called tabText
you had to include create the following code in the configuration of the dialog:
Code Block | ||
---|---|---|
| ||
form: tabs: - name: tabText fields: - name: title class: info.magnolia.ui.form.field.definition.TextFieldDefinition |
Using the fieldType
property and
...
short field names
For legibility, ease of development, and to make field names easier to remember, with Magnolia 5.7 changed this in two ways:we've introduced the fieldType
property.
- For the
fieldType
property you You no longer need to specify the field type using the a fully qualified class name. You need to set just Just provide the field's name proper via as the value of thefieldType
property.
If your project uses theclass
property .in too many places, you can still continue usingclass
. The feature is backwards compatible. - We have streamlined the definition names by making them shorter. The In selected modules (see the Short field names list below on this page ), the field name does not even require the
-Field
or -FieldDefiniton
suffix. shows which fields are affected.
Applied to the above example the configuration can now be as simple For the example with the text field this means that the configuration can look like as this:
Code Block | ||
---|---|---|
| ||
form: tabs: - name: tabText fields: - name: title fieldType: text |
To check verify that you use correct short field alias names, look in the Definitions app :
TODO
Relevance for custom fields extending or decorating Magnolia fields
Please note that the new short field naming affects:
- The origin of the definition. The fields defined previously as JCR nodes under
/modules/<module-name>/fieldTypes
folders are now defined from YAML files.
See the following example showing the definition ofdamUploadField
in Magnolia 5.6.6 and the correspondingdamUpload
definition in Magnolia 5.7:
- The file names. If a field was previously defined in a YAML file, the file's name has changed to the new short name. See for example the definition of the Expanding text field:
/content-editor/fieldTypes/expandingTextField.yaml
(in Magnolia 5.6.6)/content-editor/fieldTypes/expandingText.yaml
(in Magnolia 5.7)
Warning |
---|
If you have custom fields which reuse an existing Magnolia configuration via YAML include, YAML inherit, JCR extends or by decoration, your custom definition may be broken now if you reference a field which has changed its name. |
Short field names
Include Page | ||||
---|---|---|---|---|
|