1

I can't retrieve the checked value in checkbox. if i changed the v-model to form.permissions[index] it will show up but if i save it it will not save.

Tried this.

<table class="table table-sm">
    <tr v-for="(permission, index) in permissions" :key="permission.id">
        <td>{{ permission.name }}</td>
        <td><input type="checkbox"  class="form-check-input"  
            :value="permission.id" v-model="form.permissions[index]" checked> 
        </td>
    </tr>
</table>

but this scenario will not save/update the data.

<table class="table table-sm">
    <tr v-for="permission in permissions" :key="permission.id">
        <td>{{ permission.name }}</td>
        <td><input type="checkbox"  class="form-check-input"  
            :value="permission.id" v-model="form.permissions" checked></td>
    </tr>
</table>
 editRow(data){
    this.editmode = true;
    this.form.reset();
    this.form.clear();
    this.form.fill(data);
    $('#addNew').modal('show');
},

for the store()
 $role = new Role();
 $role->name = $request['name'];
 $role->ident = $request['ident'];
 $role->description = $request['description'];
 $role->level = $request['level'];
 $role->active = $request['active'];
 $role->save();

 $role = Role::find($role->id);
 $role->permissions()->attach($request['permissions']);
 return $role;

for update()
 $role = Role::findOrFail($id);
 $role->name = $request['name'];
 $role->ident = $request['ident'];
 $role->description = $request['description'];
 $role->level = $request['level'];
 $role->active = $request['active'];
 $role->permissions()->sync($request['permissions']);
 $role->update();

it must save and update the data and retrieve the old value.

1 Answer 1

1

Try :checked="form.permissions[index]" get rid of the v-model

Sign up to request clarification or add additional context in comments.

3 Comments

the saving is not saving and updating if using this.
what is the code that is saving? are you reffering to front end code? vue? where?
no. i use laravel as backend. i put it there. from my front-end i use api.

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.