MultifieldΒΆ

/libs/granite/ui/components/foundation/form/multifield

Multifield component allows to add/reorder/remove multiple instances of a field. In the simplest case this is a simple form input field (e.g. textfield, textarea) but it can also be a complex component acting as an aggregate of multiple subcomponents (e.g. address entry).

The field to be included is defined in the subnode named field. Regardless of the component used, Multifield assumes they all write to the same property (defined by the name property of the field subnode) thus the resulting value will always be multi value.

When rendering existing entries, the Multifield will iterate over the multi value, get each value, set it in the field and let the field render it.

For example if the field is a text field with a name value of “fruits”, and you use Multifield to add three text fields and set them with values “apple”, “orange” and “banana”, the content node will get the following property after saving:

fruits: ["apple", "orange", "banana"]

If the field is a composite, it is its responsibility to concatenate the fields into one, before the form gets submitted, and to separate them again on rendering.

It extends Field component.

It has the following content structure:

granite:FormMultifield
idstring

The id attribute.

relstring

The class attribute. This is used to indicate the semantic relationship of the component similar to rel attribute.

classstring

The class attribute.

titlestring
i18n

The title attribute.

deleteHintboolean
  1. true

true to generate the SlingPostServlet @Delete hidden input based on the field name.

field

The actual field of the Multifield.

Example:

+ myinput
  - sling:resourceType = "granite/ui/components/foundation/form/multifield"
  + field
    - sling:resourceType = "granite/ui/components/foundation/form/textfield"
    - name = "./pages"