4
I have a User Registration form, where I make available the options to select several options in Checkbox.
Registration - Sports Practice: Football, Volleyball, Swimming and etc. (Users can select several).
I’m having trouble updating records, because I need to show the fields that can be filled in the update and mark the previously chosen ones.
In the section below I only display the available items. I need to pick up the marked entry and mark as checked.
View
@foreach ($esportesas $item)
<label class="col-md-12 col-xs-12">
<input name="areas[]" value="{{ $item->id }}" type="checkbox">{{
($item->area)
}}
</label>
@endforeach
</label>
@endforeach
Controller
public function edit($id)
{
/* Dados Cadastrados */
/* Aqui utilizo um relacionamento via Eloquent utilizo Foreach para fazer a Interação Ex:
foreach ($dados->esportes as $value) {
var_dump($value->id)
}
*/
$dados = Usuarios::find($id);
/* Lista de Esportes Cadastrados para Gerar View */
$esportes = Esportes::all();
return view('/edit', compact('dados', 'esportes'));
}
Are you running that
@foreach
? For he has 2@endforeach
, this is related to another looping?– Bulfaitelo