0
votes

I have a create product for and i want to fill customer_id hidden input using blade, but user can change it while he/she is on form page. How can i pass pre selected customer id to vue product data model? here is my code:

@section('content')
    <input type="hidden" name="customer_id" value="{{ $customer->id }}" v-model="product.customer" />
@endsection

This is my vue instance:

const app = new Vue({
el: '#app',
data: {
    product: {
        'customer': null,
        'title': null,
    }
},

This code will lead both customer in vue, and customer in input field to be null.

2
Have u got a solution for your problem?Amr Aly

2 Answers

0
votes

Your data must return an object try this syntax:

data() {
    return {
      product: {
        customer: null,
        title: null,
      }
    }
}
0
votes

Use props for that and don't forget to json_encode($customer) when you pass it to the component.