-
-
Notifications
You must be signed in to change notification settings - Fork 52
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Allow returning of empty array from multicheckboxes (using use_hidden_element) #149
Comments
@tempfirstuser |
For sake of completeness, this has also been discussed in Slack: https://laminas.slack.com/archives/C4QBQUEG5/p1623930860223800 |
@froschdesign , I have this generated html code:
if I checked some checkboxes I will have POST array of categories, something like this:
But if I will not check any of checkboxes I will have value from hidded input like this:
which means instead of array I will get empty string. Was this helpful? Currently, I don't use |
I have the same HTML output and can not reproduce the error message:
So I need the definition of your form with input-filter. |
@froschdesign , actually, I have nested array. I was trying to simplify the question. I have modified my post/issue at the top. fieldset and filter from the top is all what I have. In reality I have something nested like this:
Do you have the same empty string:
? Or do you have empty array like this:
? |
Okay, this helps! 👍 Please try to override the following: laminas-form/src/View/Helper/FormMultiCheckbox.php Lines 257 to 260 in ed6c972
With: $hiddenAttributes = [
'name' => static::getName($element),
'value' => $uncheckedValue,
]; This will not work because the empty / unchecked value is always added to the array! |
Bug Report
Summary
I have multicheckoxes. I want to have ability to return empty array if non of checkboxes is checked. I use
use_hidden_element
to return hidden input element instead but it returns empty string instead of empty array.This is my fieldset config:
this is my input filter config:
this is generated hidden input:
this is generated checkbox input:
and as result I've got this exception:
The text was updated successfully, but these errors were encountered: