mardi 7 février 2017

Laravel - Elegently repopulate checkboxes or select on validation

I'm using form model binding in Laravel. Form fields can be populated with the old() method:

old('key','default')

So the first input default value comes from the database, and when validation fails, the value comes from the request.

It's just about succint enough for text inputs, but for selects and checkboxes I seem to end up with a massive list of isset() which isn't very elegant. What's the cleanest way of repopulating selects and checkboxes?

Please note - I'm not interested in answers which refer the Laravel Collective. I'm aware that this library exists but I am not using it.



from Newest questions tagged laravel-5 - Stack Overflow http://ift.tt/2kOGJ6O
via IFTTT

Aucun commentaire:

Enregistrer un commentaire