Is there a way to add input type that allows input arrays?

Is there a way to add input type that allows input arrays?

hubindustrialhubindustrial Posts: 3Questions: 2Answers: 0
edited August 2015 in Editor

I need to be able to have multiple text inputs, but all with the same name, but as an array, like this:

<input type="text" name="data[]" id="data-1" />

<input type="text" name="data[]" id="data-2" />

<input type="text" name="data[]" id="data-3" />

Notice the name value is an array.

How can I accomplish this with the Editor?

Thanks.

This question has an accepted answers - jump to answer

Answers

  • ashl1ashl1 Posts: 18Questions: 5Answers: 1

    What is the use case for that? Is Editor used as standalone or with Datatables?

    I see only two ways:

    1. Use different names and combine them on server before request proceeding
    2. Use different names and combine them on client JS before the data will be sent in preSubmit
  • allanallan Posts: 63,498Questions: 1Answers: 10,471 Site admin
    Answer ✓

    Hi,

    There isn't a built in way of of allowing text input like that, but you could readily write a little field type plug-in that allows that (it would just add the fields required and return an array as the value).

    You can use checkbox with an array of values at the moment, and 1.5.1 will introduce the ability to use select with an array of values - but these are both predetermined values.

    A final option might be to use Select2 or similar which does allow reform input and will work fine with arrays.

    Allan

This discussion has been closed.