I have a list of applicants from vuex state retrieved using the vuex getters. and from the front end side, I wat to record their respective results as an array and submit their results. but I can't assign the applicants id to v-model.
I have tried using an array and array objects but does not work. I have tried to loop the list of applicants on the page create and assign to the array data declared in Vue data.
Template Code
<template>
<table style="margin-left:10%;">
<tr>
<th>#</th>
<th>Full Name</th>
<th>Result</th>
</tr>
<tr
v-for="(applicant, key) in getApplicants"
:key="applicant.applicant_id"
>
<td>{{ key + 1 }}</td>
<td>
{{ applicant.first_name }} {{ applicant.middle_name }}
{{ applicant.last_name }}
<b-form-input v-model="record.applicant_id[key]"></b-form-input>
</td>
<td>
<b-form-input v-model="record.exam_result[key]"></b-form-input>
</td>
</tr>
</table>
<template>
script code
data() {
return {
update: false,
record: {
job_vacancy_id: null,
exam_type_id: null,
applicant_id: [],
exam_result: []
}
};
methods:{
save() {
var object = {
job_vacancy_id: this.record.job_vacancy_id,
manpower_requisition_id: this.manpower_requisition_id,
applicants_id: this.applicants_id,
exam_result: this.record.exam_result
};
console.log(object);
},
populate() {
let appliacnts = this.getApplicants;
for (var i = 0; i <= appliacnts.length; i++) {
this.record.applicant_id = this.appliacnts.applicant_id[i];
}
}
},
created() {
this.populate();
}