-
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
Add trim filter to first, middle and lastname. #12964
Add trim filter to first, middle and lastname. #12964
Conversation
The additional trim form field data filter was created and added as input filter to the firstname, lastname and middlename fields of the customer_address and customer entities. Tickets: magento#10415
I noticed the PHP code sniffer failure and will address it one of the next coming days. |
Added required new line at the end of the Magento\Framework\Data\Form\Filter\Trim class. See build reports for PR magento#12964
The required changes were committed, static tests should pass too this time. |
Added required new line at the end of the Magento\Framework\Data\Form\Filter\Trim class. See build reports for PR magento#12964
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, thank you very much for your contribution! I will process this PR and was wondering whether it might be a good idea to also filter other whitespace characters?
*/ | ||
public function inputFilter($value) | ||
{ | ||
return trim($value, ' '); |
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.
Did you find a reason to not remove other whitespaces as done by trim()
by default?
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.
I could be wrong of course, but I indeed filtered ordinary spaces only on purpose, to make sure the trim-function remains strict (matching the expected behaviour stated within the original ticket) and to avoiding unwanted removal of other characters (for example, when text area inputs should accept and store newlines, but redundant whitespaces dropped).
Other than that, no real reason to deviate from the trim()
default behaviour indeed :) Let me know if you'd prefer the default behaviour after all, I'll gladly correct the PR.
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.
Thanks for your explanation! Let's keep it like that for now. If demand shows we should trim for other whitespaces, this still can be done in the future.
@wardcapp FYI: the Commerce Edition test suite has some failing tests that need to be adjusted to the change passes. I will tell you when this has been done. |
Hi @wardcapp, thanks again for your contribution! This has been merged into |
A similar pull request was set up before (#11051), but has now been re-created (after accidentally deleting the branch that was to be merged, from my end).
Description
The additional trim form field data filter was created and added as
input filter to the firstname, lastname and middlename fields
of the customer_address and customer entities.
Fixed Issues (if relevant)
Manual testing scenarios
Contribution checklist