I am trying to create a Vue page that contains nested field collections. I.e. Parent form and repeatable child forms.
It works with the exception that when deleting a child form, the template renders incorrectly
Please see the fiddle example that I created - https://jsfiddle.net/c4marcus/1mu2oceb/8/
The sample data contains basic information for The Beatles. If you click the trash can next to "Ringo" then mistakenly "George" will disappear and not "Ringo".
However, when you click submit the correct data is being saved (see screenshot below).
I feel like the problem must lie with the MemberFormset
vue component's remove
method which is triggered by clicking the trash can button.
remove: function(index) {
this.members.splice(index, 1)
this.$emit('input', this.members)
},
Once spliced, the template should render the array of forms with the new data.
<div class="form-group" v-for="(member, index) in members">
<member-form :model="member"
:index="index"
@input="update(index, $event)">
<div slot="trash">
<button type="button"
class="btn btn-default margin-top-md"
@click="remove(index)">
<i class="fa fa-trash"></i>
</button>
</div>
</member-form>
<hr v-if="separator(index)" />
</div>