if you want to ouput checked checkbox, pass a third param true
ie:
{{ Form::checkbox('name', 'value', true) }}
Explaining on the bench there is a column with name turnos, the type set ('Morning', 'Afternoon', 'Night'). If recorded only 'Morning', 'Afternoon' and the third empty stowage want the edit view returns the three checkbox.
[v] Morning [v] Afternoon [ ] Evening
But returns as well.
<?php $course = explode(",", $curso->turno);?>
@foreach ($course as $c)
<label>{{ Form::checkbox('turnos[]', $c, true) }} {{$c}}</label>
@endforeach
sorry i don't understand you, better try you on Portuguese Stackoverflow
If you want to return all check-boxes, including "empty" (not checked) check-boxes, you has to use additional hidden fields.
A better solution is to use name like 'turnos_Manhã', 'turnos_tarde'... Then, in the POST route/controller, to create a turnos[] array with all ids of setted check-boxes, then use the array to synchronise all links in one step:
foreach ($tempos as $tempo) {
if Input::has('turnos_' . $tempo->name) {
$turnos[]=$tempo->id;
}
}
$yourobject->tempos()->sync($turnos);
Sign in to participate in this thread!
The Laravel portal for problem solving, knowledge sharing and community building.
The community