-
Notifications
You must be signed in to change notification settings - Fork 9.4k
#7241: Always add empty option for prefix and/or suffix if optional #11462
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
* @return array|bool | ||
*/ | ||
protected function _prepareNamePrefixSuffixOptions($options) | ||
private function prepareNamePrefixSuffixOptions($options, $isOptional = false) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As part of the BC guidelines you cannot remove a protected method http://devdocs.magento.com/guides/v2.2/contributor-guide/backward-compatible-development/#public-and-protected-method-removal I would suggest that you keep the private method and the internal calls to this private method and then simply add back the protected method that simply calls the private method and mark it as deprecated.
@avstudnitz do you think you will have some time to continue this PR? |
Yes, I will, probably next week. |
This is due to Backwards Compatibility reasons.
I re-added the protected method as you said @dmanners. |
Thanks @avstudnitz I will take another look over this PR for you. |
* @param bool $isOptional | ||
* @return array|bool | ||
* | ||
* @deprecated See prepareNamePrefixSuffixOptions |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You should also be able to use http://docs.phpdoc.org/references/phpdoc/tags/see.html here to link to the new method. Something like the following should work.
@see prepareNamePrefixSuffixOptions()
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Changed, makes sense.
@@ -11,15 +11,19 @@ | |||
*/ | |||
class Nooptreq implements \Magento\Framework\Option\ArrayInterface | |||
{ | |||
const VALUE_NO = ''; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sadly while putting this to the 2.2-develop
branch and with this class marked as @api
we cannot add any new constants. For a PR to 2.3-develop
we could add these new constants. For this PR we will have to change this back.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you explain why adding new constants is an issue? It doesn't affect backwards compatibility and only improves things, I don't see any disadavantage of that... sounds like a quite arbitrary rule to me, but perhaps it gets clearer if you explain.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi @dmanners in general, you are right. But in this particular, we can accept new constants. There are some cases when new constants can break client code, but the chances a very low.
@dmanners @avstudnitz thank you for collaboration
return $this->_prepareNamePrefixSuffixOptions($this->addressHelper->getConfig('prefix_options', $store)); | ||
return $this->prepareNamePrefixSuffixOptions( | ||
$this->addressHelper->getConfig('prefix_options', $store), | ||
$this->addressHelper->getConfig('prefix_show', $store) == NooptreqSource::VALUE_OPTIONAL |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Unfortunately we will need to change this since we cannot add the new constants.
return $this->_prepareNamePrefixSuffixOptions($this->addressHelper->getConfig('suffix_options', $store)); | ||
return $this->prepareNamePrefixSuffixOptions( | ||
$this->addressHelper->getConfig('suffix_options', $store), | ||
$this->addressHelper->getConfig('suffix_show', $store) == NooptreqSource::VALUE_OPTIONAL |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Unfortunately we will need to change this since we cannot add the new constants.
@avstudnitz have you had anytime to look into this PR further? There is still the part about showing the empty value in the check and also the backwards compatibility changes also. Thanks |
@dmanners I made the requested changes. Would be glad about an explanation of the forbidden constants. |
@avstudnitz thank you for the update. I will see if I can get someone to help out with the front-end part, it would be nice to have both together. With regards to the constant addition. I also agree that it is worth having in this case. Generally speaking because constants are public and the class is marked as Could you revert the revert commit and then I can ask from some approval here. Sorry for the pain. |
Thanks @dmanners, I reverted the commit. I agree that removing or changing public elements of the class would be bad, but I don't see the point for newly added functions or constants because they can be ignored. Would be great if you could get approval for that. |
@avstudnitz still trying to sort out that front end part for you. I will aim to get around to this PR in the next week. Sorry for the delay. |
…fix in checkout. - replace usage of empty string for optional value with space so that the knockout.js picks up the optional values
Description
This solves part of #7241. If the prefix and/or suffix field is set to "optional" in the configuration, we automatically add a blank first option if it isn't entered in the "Dropdown Options" configuration field.
Fixed Issues (if relevant)
Manual testing scenarios
Contribution checklist