0

I have a select and options in my form but i would like to prepopulate the select with old selected data but i can't seem to get it to work.

Here is my code

<select name="holding_id" v-model="service.holding_id">
              <option value="">Select a holding group</option>
              <option v-for="holding in holdings" v-bind:key="holding.id" v-bind:value="holding.id">
                             {{ holding.holding_name }}
              </option>
  </select>

I am thinking using javascript ternary would make sense

2
  • 1
    Does this answer your question? Set default value to option select menu Commented Jan 7, 2022 at 12:30
  • 1
    v-model will ignore the initial value, checked, or selected attributes found on any form elements. It will always treat the Vue instance data as the source of truth. You should declare the initial value on the JavaScript side, inside the data option of your component. - docs Commented Jan 7, 2022 at 12:46

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.