Currently, I am utilizing Laravel 5.7 and VueJs 2.5.* in my project. The issue I am facing is related to a Bootstrap Model that I use for creating and editing TicketInvoice and its associated TicketInvocieItems. When I try to edit, the Bootstrap Model opens with TicketInvoice data filled in, but the data of TicketInvoiceItems does not show up. I am unsure about how to populate the data of TicketInvoiceItems as well.
Here are the input fields for ticketInvoiceItems:
<tbody>
<tr v-for="(ticketInvoiceItem, key) in form.ticketInvoiceItems" :key="key">
<!--Passenger Name-->
<td>
<input v-model="ticketInvoiceItem.passenger_name" size="40" type="text" name="passenger_name" class="table-control form-control" :class="{ 'is-invalid': form.errors.has('passenger_name') }">
<has-error :form="form" field="passenger_name"></has-error>
</td>
<!--Ticket No.-->
<td>
<input v-model="ticketInvoiceItem.ticket_no" size="24" type="text" name="ticket_no" class="table-control form-control" :class="{ 'is-invalid': form.errors.has('ticket_no') }">
<has-error :form="form" field="ticket_no"></has-error>
</td>
</tr>
<!----------- THERE ARE MORE FIELDS BELOW ----------->
The HTML code for the edit button:
<a href="#" @click="editModel(ticketInvoice)">
<i class="fas fa-user-edit fa-lg text-orange"></i>
</a>
VueJs editModel() method:
<script>
/*==============EDIT INVOICE CODE==============*/
editModel(ticketInvoice) {
this.editmode = true;
this.form.reset();
this.form.clear();
$("#addNewTicketInvoice").modal("show");
this.form.fill(ticketInvoice);
},
/*==============END EDIT INVOICE CODE==============*/
</script>
My VueJs data():
<script>
export default {
data() {
return {
editmode: true,
ticketInvoices: {},
vendors: null,
form: new Form({
id: "",
vendor_id: "",
ticket_invoice_no: "",
ticket_invoice_date: "",
ticket_invoice_fares_total: "",
ticket_invoice_grand_total: "",
ticketInvoiceItems: [{
id: "",
ticket_invoice_id: "",
passenger_name: "",
ticket_no: "",
departure_date: "",
fares: "",
sub_total: 0
}]
})
};
},
</script>
For better clarity, you can refer to this image: https://i.stack.imgur.com/pL2Po.png