I don't really get what you're trying to do... Is it something like that ? (Wrong fiddle link T_T)
Dynamic Input Array
Hello all,
Hope you're all having a good weekend!
I'm currently have small form that has a couple of buttons to add and remove a new fields.
Here's what I'm currently working with: https://jsfiddle.net/joedawson/dmf2crzL/
As you can see, I already have the basic functionality down - but when I add a new row, I want to create an array of fields - how could I achieve this?
I have tried something like this:
<!-- Field Template -->
<div class="input-group" v-el:row>
<input type="text" class="form-control" v-model="template.fields[].label">
<span class="input-group-addon">
<label>
<input type="checkbox" v-model="template.fields[].sensitive"> Sensitive
</label>
</span>
</div>
Notice the template.fields[]? Vue doesn't appear to like this as it requires a key for some reason?
When I loop through each field with v-for, I'm aware that I can maybe use the $index variable - but I can't do this because I have an input outside of my v-for- therefore $index is not available.
So currently, I get a "template" that looks like this:

As you can see, I'm not getting an array of fields - but that's understandable with what I currently have. But really, I want to achieve an output looking a little something like this.
{
"name": "Name of Template",
"fields": [
{
"label": "My Custom Field Name",
"sensitive": true
},
{
"label": "Last Field Name",
"sensitive": false
}
]
}
I hope that makes sense!
Please or to participate in this conversation.