I created checkboxes in form using javascript:
<input type="checkbox" name="is_ok[]" />
<input type="checkbox" name="is_ok[]" />
<input type="checkbox" name="is_ok[]" />
When I check 1st and 3rd checkbox and submit the form, Input::get("is_ok")
returns me:
['on', 'on']
Is there any way to get value as ['on', null, 'on']
or ['on', 'off', 'on']
?
Thanks in advance.
I think I have a "good" solution to this (kind of).
(Forced indices here)
In the request:
This will ensure that (a) The checkbox indices are maintained as expected. (b) the gaps are filled when the request is received.
It's sloppy but may work.
IMHO this is the best practice:
In your migration set that db table field to boolean and default 0
and if you are not using laravel collective for forms then you can use vanilla php
My solution is this for laravel 5
Hey assign some values to checkboxes like
user_id, product_id etc
what ever in your application.E.g. View
E.g. Controller
You will get array of selected checkbox.
Hope it helps..