hello community I am implementing a shopping cart in vue js with laravel I am new and I am learning.
I would like to know if I can bind values that I have a form to data( the: form value to data data)
<div class="row no-gutters">
<!-- data distribution on card -->
<div class="col-3" v-for="(ProductSearch, index) in ProductSearchs" :key="index.id" >
<div class="card">
<img v-bind:src="ProductSearch.product_images[0].Image" title="Titulo producto" alt="titulo" class="card-img-top" width="120" height="100" >
<div class="card-body">
<span v-text="ProductSearch.name "> </span>
<span> {{ ProductSearch.sale_price }}</span>
</div>
<form method="post" v-on:submit.prevent>
<!-- data of products to be sent -->
<input :value="csrf" type="hidden" name="_token" >
<input :value="ProductSearch.id" name="id" type="hidden" class="form-control input-lg">
<input :value="ProductSearch.name" name="name" type="hidden" class="form-control input-lg">
<input :value="ProductSearch.sale_price" name="precio" type="hidden" class="form-control input-lg">
<input :value="ProductSearch.cantidad" name="cantidad" min="1" max=5 type="number" class="form-control input-lg" style="text-align:center" >
<button v-on:click="addproduct" class="btn btn-info btn-block" type="submit"> Add</button>
</form>
</div>
</div>
</div>
this data
data(){
return {
csrf: document.head.querySelector('meta[name="csrf-token"]').content,
ProductSearchs:[ ], // Get data from BD
Search: '',
setTimeoutBuscador:'',
// product data to send to card
Productos:{
id: 1,
name: 'producto 3',
precio: 1,
cantidad: 1,
}
}
},
v-modelfor that eg<input name="search" v-model="Search" />addproductmethod is triggered you want to get the data in that form to be sent via ajax to the Laravel controller method - is that right?