tenz tenz - 11 months ago 47
PHP Question

How do I data bind to a checkbox input Laravel?

Using Laravel 5.1

I have a form that I am data binding to. Everything work as expected except for the checkbox.

Here is my input (blade template);

<input type="checkbox" name="noContact" value="{{ $profile['noContact'] }}">

The field is a boolean and the checked value should be 1. Doesn't seem to be binding. What am I missing?



Maybe try to use checked="checked" instead of value attribute :

<input type="checkbox" name="noContact"{{ $profile['noContact'] ? ' checked="checked"' : '' }}>