0
votes

i am trying to bind a list of objects in v-select autocomplete using below code

<v-select
   label="name"
   id="auto_assign"
   name="auto_assign"
   item-text="name"
   item-value="id"
   :filterable="false"
   :options="itemsAutoAssign"
   v-model="params.requester_id"
   @search="getItemsAutoAssign">
      <template slot="no-options"> Type to search </template>
</v-select>

itemsAutoAssign has a structure like this

[
   {id: 1, name: 'iman1', mobile: '+989188455223'},
   {id: 2, name: 'iman2', mobile: '+989188455224'},
   {id: 3, name: 'iman3', mobile: '+989188455225'},
]

but after changing value, the params.requester_id value is an object. I need just id not whole object. I can change the value in my submit button but i need a best practice and true way.

2

2 Answers

0
votes

Changes the options to

:items="itemsAutoAssign"

0
votes

You can customize the text and value of v-select using item-text and item-value. For more information, please refer here.

Nonetheless, your code seems to be correct except v-select doesn't have options property. It should be items instead.