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

Add trim filter to first, middle and lastname. #12964

Merged

Conversation

wardcapp
Copy link
Contributor

@wardcapp wardcapp commented Jan 2, 2018

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)

  1. Customer First and Last names not being trimmed of leading and trailing spaces on save. #10415: Customer First and Last names not being trimmed of leading and trailing spaces on save.

Manual testing scenarios

  1. Create a new customer from the Customers > All Customers > Create New Customer window
  2. Create First name: "John " Last name: " Doe ", add a fake email address.
  3. Click save
  4. Search and edit the contact "John Doe "
  5. Take note that the spaces are no longer in the users first, middle and last names. Same goes for the customer names set on the customer addresses.

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)

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
@wardcapp
Copy link
Contributor Author

wardcapp commented Jan 3, 2018

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
@wardcapp
Copy link
Contributor Author

wardcapp commented Jan 3, 2018

The required changes were committed, static tests should pass too this time.

wardcapp added a commit to wardcapp/magento2 that referenced this pull request Jan 5, 2018
Added required new line at the end of the Magento\Framework\Data\Form\Filter\Trim
class.

See build reports for PR magento#12964
@mzeis mzeis self-assigned this Jan 6, 2018
Copy link
Contributor

@mzeis mzeis left a 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, ' ');
Copy link
Contributor

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?

Copy link
Contributor Author

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.

Copy link
Contributor

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.

@mzeis
Copy link
Contributor

mzeis commented Jan 7, 2018

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

@wardcapp
Copy link
Contributor Author

wardcapp commented Jan 8, 2018

Thanks for the correction and keeping me posted on this @mzeis! The latest changes you committed will probably have to be applied to the 2.3.x port of this PR (which is #13012) too (which I'm of course willing to take care of)?

@mzeis
Copy link
Contributor

mzeis commented Jan 9, 2018

Yes @wardcapp, we will need them in #13012 too. It would be cool if you can add it!

@mzeis
Copy link
Contributor

mzeis commented Jan 9, 2018

Hi @wardcapp, thanks again for your contribution! This has been merged into 2.2-develop.

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