See Multivalue field in Magnolia documentation.

MultiValueFieldDefinition renders multiple fields that allow the user to perform multi-selection. The multi value field is used to select targets inside Magnolia, for example categories for a page.

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

Here's an example configuration to select multiple categories browsing the categories workspace.

Node nameValue

 
categories

 

  
 
field
Normal link field definition
     
 
identifierToPathConverter
 
        
 
class
info.magnolia.ui.form.field.converter.BaseIdentifierToPathConverter
     
 
appName
categories
     
 
buttonSelectNewLabel
field.link.select.new
     
 
buttonSelectOtherLabel
field.link.select.another
     
 
class
info.magnolia.ui.form.field.definition.LinkFieldDefinition
     
 
fieldEditable
false
     
 
targetWorkspace
category
     
 
type
String
  
 
class
info.magnolia.ui.form.field.definition.MultiFieldDefinition
  
 
label
dialogs.generic.tabCategorization.categories.label
  
 
buttonSelectAddLabel
field.link.select.add
  
 
description
dialogs.generic.tabCategorization.categories.description

Storing strategy

By default the transformerClass is set to MultiValueTransformer .

Assume that your MultiValueField is called 'multi' and contains a list of text fields. The  values will be stored as following:

Node nameValue
 
multi
text value field 1, text value field2

Configuration

You can use all common field properties and the following:

PropertyDescriptionDefault value
field
Parent node of one field composing the multi field. Mandatory. 
   classClass definition of the field 
   ...
Continue with field definition 
   ...Add any number of field definition that should composed the composite field. 
buttonSelectAddLabelButton label. Default is "Select new...", retrieved from a message bundle. Optional. 
buttonSelectRemoveLabelRemove Button label. Default is "Remove", retrieved from a message bundle. Optional. 
transformerClass Custom Transformer definition. Optional.

 


  • No labels

2 Comments

  1. Could you please tell how to make $type: jcrMultiField are mandatory. As suggested in documentation, I tried using required: true.  But the field did not considered as mandatory. Even I tried defining sub field under Multifield also mandatory. But it did not help.

    I would appreciate if you update document if it is a limitation at Magnolia end.  


    1. Hello mamatha Shivanna

      I think this was not yet implemented in 6.2. I was looking through the changelog for 6.2.3 (released yesterday) and I don't see anything specific about that setting (see https://jira.magnolia-cms.com/issues/?filter=20126) but I think you should try and update. It might have been fixed under a more generic ticket regarding common field properties. 

      If not, let me know and I will create a bug report.

      Cheers!