Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

muazzamazaz's avatar

how add dynamic v-model

<div v-for="(q, index) in questions" >
      
          <BreezeLabel for="name" />{{q.question}}
          <BreezeInput
             :id="'q_' + q.id"            
            type="number"
            class="mt-1 block w-full"
            :v-model="'q_' + q.id"
          />
          </div>

Issue is if I add `:v-model` the value is `null` on submit and if I use `v-model` then dynamic variable `"'q_' + q.id"` cannot be added and gives vue compilation error
0 likes
4 replies
MaverickChan's avatar

because you need to define the variables first. Otherwise v-model cannot find it to add

MaverickChan's avatar

@muazzamazaz i would say , you need to pass the id as a property, then in the input component , you can use v-model , then emit to parent component.

Please or to participate in this conversation.