I have a form that's generated through a v-for.
Note: I'm using "@" to escape blade.
My vue isstance has:
data: {
form: {
inputs: [{icon: "", name="", placeholder: "", type="", value=""}]
},
owner: {first_name: "", last_name: "", cell_phone: "", email: ""}
}
I generate the form with:
<template v-for="input in form.inputs">
<div style="margin-bottom: 25px" class="input-group">
<span class="input-group-addon"><i class="glyphicon glyphicon-@{{input.icon}}"></i></span>
<input id="login-@{{input.name}}" v-model="?????" type="@{{input.type}}" class="form-control" name="@{{input.name}}" placeholder="@{{input.placeholder}}">
</div>
</template>
I want to bind each input to their respective contractor property. So I want the v-models values to be owner.first_name, owner.last_name, owner.cell_phone, and owner. email. I was hoping I could do:
v-model="'owner' + @{{input.name}}"
But I get:
[Vue warn]: v-model="'owner' + {{input.name}}": attribute interpolation is not allowed in Vue.js directives and special attributes.
vue.js:1956 Error: Warning Stack Trace
at warn (vue.js:1956)
at Directive.bind (vue.js:4507)
at Directive._bind (vue.js:8668)
at linkAndCapture (vue.js:7367)
at compositeLinkFn (vue.js:7345)
at new Fragment (vue.js:5373)
at FragmentFactory.create (vue.js:5575)
at Directive.create (vue.js:5844)
at Directive.diff (vue.js:5757)
at Directive.update (vue.js:5692)
The owner properties correspond to the input.name for each input.
Thanks
Description of the app: I am trying to build an owner by using multiple forms. Each form is generated through ajax request that gets a form object which contains the inputs n and the action for that form.
You could try this:
v-model="owner[input.name]"
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With