The 5.7 branch of Magnolia reached End-of-Life on December 31, 2023, as specified in our End-of-life policy. This means the 5.7 branch is no longer maintained or supported. Please upgrade to the latest Magnolia release. By upgrading, you will get the latest release of Magnolia featuring significant improvements to the author and developer experience. For a successful upgrade, please consult our Magnolia 6.2 documentation. If you need help, please contact info@magnolia-cms.com.

You are viewing an old version of this page. View the current version.

Compare with Current View Page History

« Previous Version 31 Next »

This page describes two ways in which you may define the type of a field in a form.

When creating a form for 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 and sending it to a server after the user hits the form's submit button. 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.

Using the class property

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 create the following configuration:

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, field type definition has changed in the Magnolia 5.7 branch:

  • You no longer need to specify the field type using a fully qualified class name. Just provide the field's name as the value of the new fieldType property.
  • 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. 

Applied to the above example the configuration can now be as simple as this:

form:
  tabs:
    - name: tabText
      fields:
        - name: title
          fieldType: text

To verify that you use correct short field names, look in the Definitions app:

Relevance for custom fields extending or decorating Magnolia fields

Please note that the new short field naming affects:

  • The origin of the definition. The renamed fields defined originally as JCR nodes under /modules/<module-name>/fieldTypes folders are now defined in YAML files (in the classpath).
    See the following example showing the definition of damUploadField in Magnolia 5.6.6 and the corresponding damUpload definition in Magnolia 5.7:



  • The file names, if the field is defined via a YAML file, e.g. the definition of the Expandable 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 includeYAML inheritJCR extends or by decoration, your custom definition may be broken now if you reference a field which has changed its name.

Short field names

Old nameNew nameSince
UI module

basicTextCodeField

(warning) Removed, previously deprecated.

code5.7
basicUploadFieldbasicUpload5.7
checkBoxFieldcheckbox5.7
compositeFieldcomposite5.7
dateFielddate5.7
hiddenFieldhidden5.7
linkFieldlink5.7
linkFieldSelectlinkFieldSelection5.7
multiFieldmultiValue5.7
nodeTypeFieldnodeTypeSelect5.7
optionsFieldoptionGroup5.7
passwordFieldpassword5.7
selectFieldselect5.7
staticFieldstatic5.7
switchableFieldswitchable5.7
textArearichText5.7
textFieldtext5.7
twinColSelectFieldtwinColSelect5.7
workbenchFieldworkbench5.7
DAM module
damUploadFielddamUpload5.7
damWorkbenchFielddamWorkbench5.7
Content tags module
tagFieldtag5.7
taggingAwareDependenciesFieldtaggingAwareDependencies5.7
Content dependencies module
referenceFielddependencies5.7
Content editor module
articleBlockPickerblockPicker5.7
collapsibleCompositeFieldcollapsibleComposite5.7
expandingLinkFieldexpandingLink5.7
expandingTextFieldexpandingText5.7
peekFieldpeek5.7
placeholderTextplaceholderText5.7
refreshableTextFieldrefreshableText5.7

  • No labels