Search code examples
javascriptjqueryjsonlaravelalpacajs

Javascript: using brackets in alpacajs form name fields?


I'm trying to create a multiple select field with this output:

<select id="alpaca41" multiple="multiple" name="metrics[]" class="alpaca-control form-control"></select>

The brackets in the name are important, beceause it tells laravel that this form field returns multiple values.

When I give the alapaca form fields a name with brackets in the JSON alpaca config, they wont show in the HTML. The brackets are transformed to an underscore. This is the result:

<select id="alpaca41" multiple="multiple" name="metrics_" class="alpaca-control form-control"></select>

Replacing the brackets with ASCII code wont do the trick. :(

So my question: how do you get brackets in alpaca form fields?


Solution

  • Answer given by @vert3x in the comments of the original post. The name field was used in the schema section and not in the options section.

    http://jsfiddle.net/vert3x/5xjtkcg2/