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

kevinwakhisi's avatar

Populate data

i am tring to populate data in my edit modal form. i works well with strings but not when i try arrays. My issue here is i have roles and each roles have permissions, i am using spatie/permissions package. https://spatie.be/docs/laravel-permission/v4/basic-usage/basic-usage

showEditModal(role, index) {
       let obj = {
                id: role.id,
                name: role.name,
                permissions: role.permissions
         };
        console.log(role.permissions)
        this.editData = obj;
        this.editModal = true;
        this.index = index;
},

the edit form only shows the role name but not the permissions associated with the role


<Modal v-model="editModal" title="Edit Role" :mask-closable="false">
            <Input
                v-model="editData.name"
                size="large"
                maxlength="15"
                show-word-limit
                placeholder="Create role, Name"
            />
            <div class="space"></div>
            <Select
                prefix="ios-album-outline"
                filterable
                multiple
                v-model="editData.permissions"
                clearable
                placeholder="Select Roles"
            >
                <Option :value="p.id" v-for="(p, i) in permissions" :key="i">
                    {{ p.name }}
                </Option>
            </Select>

            <div slot="footer">
                <Button type="default" @click="editModal = false">
                    Close
                </Button>
                <Button type="primary" @click="editRole"> Edit Role </Button>
            </div>
        </Modal>
0 likes
2 replies
kevinwakhisi's avatar

i don't know how can i send this picture? but i can explain the output. The first displays the total permissions in the particular role selected, the second displays all permissions available from my permissions table. To make it even more easier for your analysis , i am using iview ui theme https://www.iviewui.com/components/select-en#Multiple

Please or to participate in this conversation.