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

SelectFieldDefinition renders a dropdown list.

class: info.magnolia.ui.form.field.definition.SelectFieldDefinition

fieldType: select

Example select field definition

form:
  tabs:
    - name: tabLink
      label: Link
      fields:
        - name: listStyle
          fieldType: select
          label: List style
          options:
            - name: bullet
              value: bullet
              selected: true
              label: Bullet
            - name: ordered
              value: ordered
              label: Ordered
            - name: inline
              value: inline
              label: Inline
Node nameValue

 form


 tabs


 tabLink


 fields


 listStyle


 options 


 bullet


 label

Bullet

 selected

true

 value

bullet

 ordered


 label

Ordered

 value

ordered

 inline


 label

Inline

 value

inline

 fieldType

select

 label

Link

See Referencing fields for further information.

Select field properties

The select, option group and twin-column fields share this general configuration pattern, but they also have their own additional properties.

<field name>

required

Name of the field.

options

optional

Parent node for the selectable options. If not set, the field generates options from the repository path.

<option name>

Name of the option.

value

required

Value saved to the repository when selected.

name

optional, default is the parent node name

Name of the node where the selected value is stored. If not set, the name of the parent node is used.

label

optional

Option label displayed to the user.

iconSrc

optional

Displays an image next to the option. Value is a path to the image.

selected

optional, default is false

Pre-selects the option.

labelProperty

optional, default is label

Reads option labels from a different property. Set to the name of your custom label node.

path

optional

Path to existing options as opposed to defining options in the current definition. Only valid with a field defined in XML.

Alternatively, option definitions can be placed in a YAML file referenced via include.

repository

optional, default is RepositoryConstants.CONFIG

When using a path to existing options, workspace to look in.

sortOptions

optional, default is true

By default, option labels are sorted alphabetically. When false, sorts the options by JCR node order.

comparatorClass

optional, default is info.magnolia.ui.form.field.factory.SelectFieldFactory.DefaultOptionComparator

When sortOptions set to true, sorts the available options.

valueProperty

optional, default is value

Reads option values from a different property. Set to the name of your custom value node.

Additional properties

textInputAllowed

optional, default is false

When true, the user can type into the select field to filter the available options. The filteringMode property defines how the options are filtered.

When false, the field behaves like a standard select field where the user cannot enter text. Clicking the field opens the dropdown with options.

(warning) This property does not make it possible to enter new values into the field. The user can only choose from existing options.

filteringMode

optional, default is off

Vaadin FilteringMode. Available values are contains and startswith.

(warning) To enable filtering, you must also:

  • Set the pageLength property to a value greater than 0.
  • Set the textInputAllowed property to true.

pageLength

optional, default is 0

To enable paging and filtering, value must be an integer greater than 0. Value of 0 disables paging and filtering.

See also Common field properties.

Filtered select field

Here is an example select field that uses the startswith filtering mode and 10 options per page.

form:
  tabs:
    - name: tabAddress
      fields:
        - name: country
          fieldType: select
          label: Country
          filteringMode: startswith
          pageLength: 10
          textInputAllowed: true
          options:
            - name: afghanistan
              value: afghanistan
            - name: argentina
              value: argentina
            - name: australia
              value: australia
            - name: austria
              value: austria
            - name: belgium
              value: belgium
            - name: brazil
              value: brazil
            - name: bulgaria
              value: bulgaria
            - name: canada
              value: canada
            - name: chad
              value: chad
            - name: chile
              value: chile
            - name: china
              value: china
            - name: cuba
              value: cuba
            - name: czech-republic
              value: czech-republic
            - name: denmark
              value: denmark
Node nameValue

 form


 tabs


 tabAddress


 fields


 country


 options


 afghanistan


 value

afghanistan

 argentina


 value

argentina

 australia


 value

australia

 austria


 value

austria

 belgium


 value

belgium

 brazil


 value

brazil 

 bulgaria


 value

bulgaria 

 canada


 value

canada 

 chad


 value

chad 

 chile


 value

chile 

 china


 value

china 

 cuba


 value

cuba 

 czech-republic


 value

czech-republic 

 denmark


 value

denmark

 fieldType

select

 filteringMode

startswith

 pageLength

10

 textInputAllowed

true