Creating a checkbox list with a dynamic id and name:
Data:
yards[{id:1,name:'test'}] etc
HTML:
<ul class="checkbox-list">
<template v-for="(yard, index) in yards">
<li>
<input type="checkbox"
v-bind:id="'yardlist_'+yard.name"
v-bind:value="yard.id"
v-model="newSchedule.yards.id">
<label v-bind:for="'yardlist_'+yard.name">{{ yard.name }}</label>
</li>
<li>
<input type="text"
class="form-control"
placeholder="Yard notes..."
v-model="newSchedule.yards.notes">
</li>
</template>
</ul>
Storing selected checkboxes with id and notes field in an array:
newSchedule: {
due_at: '',
notes: '',
users: [],
yards: [{id:'',notes:''}]
}
Error encountered when trying to access the index from the yards array: newSchedule.yards[index].notes - "TypeError: undefined is not an object (evaluating 'newSchedule.yards[index].id')"
Looking for suggestions on how to achieve this?
** Update ** Check out this example of what I'm looking to accomplish: https://jsfiddle.net/j7mxe5p2/13/