I want to set check-boxes state from database, so I write,
{{ Form::checkbox('asap', null, $offer->asap) }}
But if I want to set 'id' to the check-box like
{{ Form::checkbox('asap', null, $offer->ASAP, array('id'=>'asap')) }}
It always set my check-box state to true. (Before user select it)
So question how set 'id' in blade check-boxes when check-box state is set before user select it?
Best Answer
I know this question was answered before, in this one I am going to explain step by step how to implement checkboxes with Laravel/blade with different cases ...
So in order to load your checkboxes from the database or to test if a checkbox is checked :
First of all you need to understand how it works, as @itachi mentioned :
Example :
How to get checkboxes values ? ( in your controller )
Methode 1 :
Methode 2 :
Note : you need to assign a default value for unchecked box :
this is nice right ? but how could we set checked boxes in our view ?
You can also get it like this :
Okey now how to deal with :
let's say we want to get working days from our database
I've spent sometime to figure out how to deal with multiple checkboxes I hope this can help someone :)