How would it work if I want to commit the input value and the selected options in the Vuex store (without the "label" string so that the object I send matches my Vuex store object) ?
Template
<div v-for="(section, indexSections) in sections" :key="indexSections">
<div v-for="(item, indexItem) in section" :key="indexItem">
<div>
<select
v-model="sections[indexSection][indexItem].options"
:options="selectOptions"
></select>
<b-input
type="text"
v-model="sections[indexSection][indexItem].sectionItem"
></b-input>
<b-button @click="removeItem({section,item})"/>
</div>
</div>
<div">
<b-button @click="addNewItem(section)"/>
<b-button @click="addNewSection"/>
</div>
</div>
Data
selectOptions: [
{
options: { option1: true, option2: true },
label: "First"
},
{
options: { option1: false, option2: true },
label: "Second"
}
]
Computed
Computed: {
sections: {
get() {
return this.$store.state.sections;
}
}
Store
sections: [
[{
sectionItem: "",
options: {
strict: true,
includes: true
}
}]
],
select
tag does not have anoptions
attribute. You need to put av-for
on anoption
tag within yourselect
. Also, yoursections
property should just be an array of objects, not an array or arrays. – Paul Bovis