[Vuejs]-Buefy select v-model does not store key but the value

0👍

You have the wrong variable in the wrong place. If you want the "key" to be the "value" in the v-model when selected, then you need to use :value="key".

<b-select v-if="roles" v-model="invitationRole" :placeholder="$t('company.users.invitation.roles-placeholder')">
    <option v-for="(value, key) in roles"
        :value="key">
        {{ value }}
    </option>
</b-select>

To make more sense of this, try this:

<b-select v-if="roles" v-model="invitationRole" :placeholder="$t('company.users.invitation.roles-placeholder')">
    <option v-for="(roleName, roleKey) in roles"
        :value="roleKey">
        {{ roleName }}
    </option>
</b-select>

Leave a comment