I have database records that are saved in json. In edit form I want those check boxes checked if, the values are saved in database.
Database Value
| ID | items |
|----|----------------------------|
| 1 | ["cars","bikes","planes"] |
| 2 | ["fruits", "vegetables"] |
Form
<input type="checkbox" name="items[]" value="cars">
<input type="checkbox" name="items[]" value="planes">
Controller
$items= Items::pluck('items');
return view('edit', compact('items'));
I tried
<input type="checkbox" name="items[]" value="cars" >
and
<input type="checkbox" name="items[]" value="cars" >
But none of them worked.
Aucun commentaire:
Enregistrer un commentaire