-
Notifications
You must be signed in to change notification settings - Fork 9.3k
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
Fix saving of empty multi select input #6899
Conversation
When you save an empty multi select input originally it sent an empty array, which was filtered out by the magento2-base/lib/web/mage/utils/objects.js::flatten() method and it was not sent to the backend for save. This fix changes the empty array to an empty string, which will be passed to the backend and it saves it as empty value properly
I'm not sure where you're seeing this issue come up, but I ended up fixing a very similar issue with a custom multiselect by adding this to the |
Oh, ok. Somehow I missed the original issue part of this. Either way, my comment may help others looking for how to solve the "problem" I was having. |
This patch killed the attribute-set switcher (in 2.1.3) with the javascript error "Uncaught TypeError: Cannot read property 'length' of undefined". To fix it I changed: Many thanks for the patch though. |
@wigman Thanks for the upgrade! :) |
The patch sometime doesn't save the input in CE 2.13. |
@nagno you're welcome. I noticed you updated the normalize function, not sure this has the same effect as where I changed it: in the onUpdate function. |
I reported this issue 6 months ago via the partner portal as well and now we finally got a working patch (the first attempt from them was not working), which is different than my solution, so I will close this pull request. |
The original issue is described here: #6281
When you save an empty multi select input originally it sent an empty array, which was filtered out
by the magento2-base/lib/web/mage/utils/objects.js::flatten() method and it was not sent to the
backend for save. This fix changes the empty array to an empty string, which will be passed to
the backend and it saves it as empty value properly