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 thename
property of thefield
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
- granite:FormField
- 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.
- requiredboolean
Indicates if the field is mandatory to be filled.
- validationstring
- multiple
The name of the validator to be applied. E.g.
foundation.jcr.name
. See validation in Granite UI.
-
deleteHintboolean
- true
true
to generate the SlingPostServlet @Delete hidden input based on the field name.
- typeHintstring
The value of SlingPostServlet @TypeHint.
- 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"
-
granite:FormMultifield