Search code examples
dialogmagnoliamultivalue

Magnolia Multivalue Field- start with one option


I have created a multivalue field in a dialog and it looks like this when I initially open the dialog:

Dialog with no options

Is there any way to have it display the field(s) necessary to create the first option when the dialog first opens? This is how we want it to look:

Dialog showing field to enter first option

I have looked through the documentation and I could not find a way to accomplish this, but I thought I would ask before telling the designers 'no.'

Thanks for your help!


Solution

  • You need to customize multivalue field to achieve it.

    Create your own field factory by extending info.magnolia.ui.form.field.factory.MultiValueFieldFactory<D> in extended factory override createFieldComponent() and once field is initialized (e.g. by calling super.createFieldComponent()) you can add the first option you wanted programatically.

    You might have to also tweak transformer or saving of the field to not save empty option if it doesn't do that already ootb.