Skip to content

Empty option label should always be a space even if attribute is required #18221

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

Conversation

VincentMarmiesse
Copy link
Contributor

Description

When adding an empty option, Magento checks if the attribute is required or not. If it's not required, it adds an empty option with a space label ( ), but if it's required it adds an empty option without label.

The issue is when an attribute is required, the empty option is not selected by default, it's the first option. It causes some issues because if the admin does not pay attention, he/she will save the product with the first option. That's not what is expected, we want an error message telling this attribute is required.

Manual testing scenarios

Before this PR

  1. Create a dropdown attribute with some options - let's say Option 1, Option 2, Option 3
  2. Set it required
  3. Create a new product without touching this attribute
  4. The product is created with Option 1 as value for this attribute

After this PR

  1. Create a dropdown attribute with some options - let's say Option 1, Option 2, Option 3
  2. Set it required
  3. Create a new product without touching this attribute
  4. The product is not created, an error message tells this attribute is required

Contribution checklist

  • Pull request has a meaningful description of its purpose
  • All commits are accompanied by meaningful commit messages
  • All new or changed code is covered with unit/integration tests (if applicable)
  • All automated tests passed successfully (all builds on Travis CI are green)

@magento-cicd2
Copy link
Contributor

magento-cicd2 commented Sep 24, 2018

CLA assistant check
All committers have signed the CLA.

@magento-engcom-team
Copy link
Contributor

Hi @VincentMarmiesse. Thank you for your contribution
Here is some useful tips how you can test your changes using Magento test environment.
Add the comment under your pull request to deploy test or vanilla Magento instance:

  • @magento-engcom-team give me test instance - deploy test instance based on PR changes
  • @magento-engcom-team give me $VERSION instance - deploy vanilla Magento instance

For more details, please, review the Magento Contributor Assistant documentation

@VincentMarmiesse
Copy link
Contributor Author

@magento-engcom-team give me test instance
@magento-engcom-team give me 2.3 instance

@magento-engcom-team
Copy link
Contributor

Hi @VincentMarmiesse. Thank you for your request. I'm working on Magento instance for you

@magento-engcom-team
Copy link
Contributor

Hi @VincentMarmiesse, here is your new Magento instance.
Admin access: https://pr-18221.engcom.dev.magento.com/admin
Login: admin Password: 123123q

@VincentMarmiesse
Copy link
Contributor Author

@magento-engcom-team give me 2.3-develop instance

@magento-engcom-team
Copy link
Contributor

Hi @VincentMarmiesse. Thank you for your request. I'm working on Magento 2.3-develop instance for you

@magento-engcom-team
Copy link
Contributor

Hi @VincentMarmiesse, here is your Magento instance.
Admin access: https://i-18221-2-3-develop.engcom.dev.magento.com/admin
Login: admin Password: 123123q
Instance will be terminated in up to 3 hours.

@VincentMarmiesse
Copy link
Contributor Author

Thanks bot :)
Here is the config I defined on both instances for the color attribute:

Option Value
Options Red, Black, Blue
Values Required Yes

When I try to create a new product on vanilla 2.3:
screen_2018092422d5

Red is the default value.

On my PR instance:
screen_20180924a406

Color is empty by default and will trigger an error if the admin tries to save to product without setting a color.

@slavvka slavvka self-assigned this Sep 25, 2018
@VincentMarmiesse VincentMarmiesse force-pushed the add-empty-label-even-if-required branch from 4f29b7c to 24055c5 Compare September 27, 2018 14:37
@VincentMarmiesse
Copy link
Contributor Author

Hi @slavvka,
I just pushed a fix for the tests error on the php doc function.
There is still an error on the description of the class but I don't know what to set here and the other classes don't seem to have a description either.

Please tell me if you want me to do some modifications.

@slavvka
Copy link
Member

slavvka commented Sep 27, 2018

Hi @VincentMarmiesse. There was recently introduced a new docblock validator which is run again changeset. That is why other classes which weren't touched don't have the same issues. I would appreciate if you added a description for this class. Please come up with its name on your own since you are aware what it is designed for. Thank you!

@slavvka
Copy link
Member

slavvka commented Sep 27, 2018

@VincentMarmiesse VincentMarmiesse force-pushed the add-empty-label-even-if-required branch from 24055c5 to 5b6152d Compare September 28, 2018 18:54
Copy link
Member

@slavvka slavvka left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you!

@magento-engcom-team
Copy link
Contributor

Hi @slavvka, thank you for the review.
ENGCOM-3075 has been created to process this Pull Request

@magento-engcom-team magento-engcom-team merged commit 5b6152d into magento:2.3-develop Oct 12, 2018
magento-engcom-team pushed a commit that referenced this pull request Oct 12, 2018
@magento-engcom-team
Copy link
Contributor

Hi @VincentMarmiesse. Thank you for your contribution.
We will aim to release these changes as part of 2.3.1.
Please check the release notes for final confirmation.

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.

4 participants