jeudi 31 mars 2016

Laravel | Checkbox state on edit page

I have a create page for a new Case in Laravel 5, where I can link services to the case. The services are checkboxes in my createCaseForm. The services are stored in the DB so I write to a ManyToMany table to have many Cases which have many services.

Example: When I create case1, I check the boxes for service1 and service3. So now the manyToMany table is filled in correctly. Now when I go to the edit page for the case I want the checkbox1 and checkbox3 to be checked by default, because they are already linked in the manyToMany table.

I know you can use something like Input::old('username'); for textfields, but I don't know how to do this for a checkbox.

I do use LaravelCollective most of the time, but for these checkboxes I didn't. So preferably I would like a HTML solution, IF POSSIBLE ofcourse.

Thanks




Aucun commentaire:

Enregistrer un commentaire