Skip to content
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

Closed
wants to merge 2 commits into from
Closed

Fix saving of empty multi select input #6899

wants to merge 2 commits into from

Conversation

nagno
Copy link

@nagno nagno commented Oct 6, 2016

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

Norbert Nagy added 2 commits October 6, 2016 11:14
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
@adprocas
Copy link

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 system.xml entry for it: <can_be_empty>1</can_be_empty>

@nagno
Copy link
Author

nagno commented Dec 21, 2016

@adprocas You can't create a system.xml entry for a product attribute. If you read the original github issue (#6281) you will see the exact steps to replicate it.

Come-on Magento, you can do better... The number of open PRs just increasing along with the number of open issuses...

@adprocas
Copy link

adprocas commented Jan 1, 2017

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.

@wigman
Copy link
Contributor

wigman commented Jan 7, 2017

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:
if (this.value().length == 0) {
to:
if (this.value() && this.value().length == 0) {

Many thanks for the patch though.

@nagno
Copy link
Author

nagno commented Jan 10, 2017

@wigman Thanks for the upgrade! :)
I tested it with 2.1.2 (EE) only and since that 2.1.3 came out. I really hope someone will check it from Magento and merge it before it will become completely outdated.

@TClilMouse
Copy link

The patch sometime doesn't save the input in CE 2.13.
Sometimes it does sometimes it doesn't. Not sure why.

@wigman
Copy link
Contributor

wigman commented Jan 19, 2017

@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.

@nagno
Copy link
Author

nagno commented Apr 19, 2017

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 solution is probably going to be included in one of the next Magento releases.

@nagno nagno closed this Apr 19, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants