I am building a page containing a number of checkboxes. html is like:
<input type="checkbox" name="gallery[]" value="gal1">
<input type="checkbox" name="gallery[]" value="gal2">
<input type="checkbox" name="gallery[]" value="gal3">
I want to have the name of checkbox (gallery) even if user doesn't choose any item.
so i added a hidden input with the same name(gallery) but in this case even if user select any checkbox , the array received in backend would be :
[
"gallery" => ""
]
even if user choose any checkbox item.
so this method would not be eligible.
because of the page structure(this page is generating according to user selections in its previous page ) i don't Know what would be the name of checkboxes in this page.also i'm not going to use session. maybe using JQuery solve the issue but i'm trying to avoid that.
so if user doesn't choose any checkbox i want to have:
$_POST : ["gallery" => '']
and if user choose any checkbox then i should have:
$_POST: ["gallery" => ['gal1', 'gal2', ...]]
is there any html base approach to this problem?