I tried to multiple select with select2 i used laravel and my data on userRoles is returned data on User model with relation roles, and allRoles is just all in Role model
my code vue
export default {
props: {
user: {
required: true,
type: Object
},
roles: {
required: true,
type: Array
},
},
data() {
return {
.....
allRoles: this.roles,
userRoles: this.user.roles,
}
},
...
and code on view
<select class="form-control" name="roles[]" id="roles" multiple>
<option v-for="role in allRoles"
:value="role.id"
>
@
</option>
</select>
how to set selected options using userRoles array?
via Chebli Mohamed
Aucun commentaire:
Enregistrer un commentaire