Page tree
Skip to end of metadata
Go to start of metadata

SwitchableFieldDefinition renders a complex field that display fields based on selections (select list or radio buttons).

Class: info.magnolia.ui.form.field.definition.SwitchableFieldDefinition

Here is an example coming from the main configuration menu of the form module.
Code is selected:

and if you click on link, the Link field is displayed instead of the Code field:


Node nameValue








Storing strategy

By default the transformerClass is set to SwitchableTransformer.

Let's take the previous example and assume that:

  • We enter a value for each field
    • code: 'some code'
    • text: 'some text'
    • link: '1b106efa-3b4f-41d3-aae6-cf368a9667b9'
  • The selected option was text.

Then the following properties are stored in the JCR repository:

Node nameValue
 confirmContentTypetextsome text
 confirmContentTypecodesome code


 You can use all common field properties and the following:

PropertyDescriptionDefault value
Parent node for the selectable options. 
   valueName of the related field definition(info).
This value is saved to the repository when this option is the last displayed/selected. Mandatory.
   iconSrcDisplays an image next to the option. The value is a path to the image. Optional. 
   labelThe option label displayed to the user. Optional. 
   selectedPre-selects the option. Optional.false
Parent node containing the single field that composed the switchable field. 
   field1Parent node of one field composing the composite field.
Field name should match the option value(info).
     classClass definition of the field1 
Continue with field1 definition 
   ...Add any number of field definition that should composed the composite field. 
classSwitchableFieldDefinition class name. Mandatory. 
selectionTypeDisplay the options as radio button or as a selection list.
transformerClassCustom transformer  definition. Optional.
layoutDefine the select option layout in case of selectionType=radio . Layout of the radio button could be
vertical  or horizontal . Optional.



  • No labels