Jump to content

How to overwrite mobile phone before save to database?


OlenLja

Recommended Posts

Hi! I need to automatic overwrite mobile phone number into special format before save to database. Where can I do it? In what controller or class?

for example, user enter phone in format (XXX) XXX-XX-XX, and there is +38XXXXXXX in database.

Link to comment
Share on other sites

If you've already got the mobile phone number being validated in (XXX) XXX-XX-XX format, I suggest overriding the add and update functions in classes/Address.php to check the format of the phone number is in +38XXXXXXX and change it if necessary before calling the parent function.

Link to comment
Share on other sites

It depends whether you have the phone number validated in (XXX) XXX-XXX-XX format. If it isn't being validated in that format, you'll need to override AuthController and OrderOpcController controllers to add that validation. If it's already being validated, then you only need to override classes/Address.php to read and write the phone number in the right way. You'll need to override the __construct() function to remove the +38 and the add and update functions to add the +38.

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...