I seem to remember having this problem before when using form model binding. I believe I resolved it by making sure the value in the model that corresponds to the checkbox is a boolean.
L5 Form checkbox returns always checked
Hello there, as some of us know this kind of a problem with checkboxes was/is still open. Currently I'm developing with L5 and Illuminate Html package and I'm getting this problem again. The interesting part is that I could fix this problem in L4 with some tweeks but now nothing works. It always returns as checked. Maybe someone has a clue what could be the problem or there is a solution that I don't know about?
Currently I'm trying this method of Form model binding. The code in my controller that makes an array key for the checkbox if it containts relationship.
// ItemController.php
if ($prop->items->contains($id))
$data['props'][$prop->id] = $prop->id;
My form looks like this.
{!! Form::model($data, ['route' => ['admin.item.edit.post', $data['id']]]) !!}
And the checkbox like this.
{!! Form::checkbox('props['.$prop->id.']', $prop->id) !!}
As this relationship do exist and the correct array key is created the checkbox is checked but when I uncheck it and post data, the model gives me checked input.
Please or to participate in this conversation.