dimanche 29 mars 2020

Laravel - old() value of checkbox, in combination with the one loaded from the database

I have this checkbox code:

<div>
     <input type="checkbox" id="allowfullscreen" name="allowfullscreen"
                                 >
</div>

This checks the checkbox based on the value taken from the database. Now, i would like to implement also the old data, in case of a failed submission.

For textboxes i do it like this:

<input id="galname"
                        type="text"
                        class="form-control @error('galname') is-invalid @enderror"
                        name="galname"
                        value=""
                        required autocomplete="galname" autofocus>

But it does not work this way for checkboxes since they need checked to be printed. The samples I found around here on SO only adress one of the two situations, but didnt find any that address both things for checkboxes.

How can this be done?




Aucun commentaire:

Enregistrer un commentaire