1

i stack with livewire Update with checkbox array please help. Form

<form wire:submit.prevent="Update" class="py-3 mb-6">
    @foreach ($permissions as $key => $pms)
        <input type="checkbox" model:wire="PermissionCheckbox.{{ $key }}" {{ in_array($pms->id , $PermissionCheckbox)? "checked":"" }} />
    @endforeach
    <button class="btn btn-primary" type="submit">Update</button>
</form>

Php Function

public function Edit($id){
 $role = Role::find($id);
 $this->roleId = $role->id;
 $this->roleName = $role->name;
 $this->PermissionCheckbox = json_decode($role->permissions->pluck('id'));
}
public function Update(){
$this->validate([
    'roleName' => 'sometimes|required|unique:roles,name,'.$this->roleId,
    'PermissionCheckbox' => 'required'
]); 
dd($this->PermissionCheckbox);
}

The result not update with the PermissionCheckbox. Thank you in advance guys.

Koung Buntha
  • 135
  • 1
  • 1
  • 9

1 Answers1

1

check your input because it has the wire model inverted the correct is wire:model

<input type="checkbox" wire:model="PermissionCheckbox.{{ $key }}" {{ in_array($pms->id , $PermissionCheckbox)? "checked":"" }} />