Problem/Motivation

One of the biggest challenges with the current Telephone module is that it's just a glorified textfield. It has no option to normalize the telephone number - either for the purpose of validation or formatting.

In Commerce applications, we see more and more requirements from payment gateways to collect and pass the telephone number to the payment gateway during Checkout. Given we have payment gateways from all over the world, supporting customers in virtually every possible market, we also must be able to process and send the phone number in a normalized way.

Fortunately, 2 standards are leading here:
- E.164 - the international public telecommunication numbering plan
- national format - popular if only supporting customers in one market

Google came up with the library that is now an unofficial standard, that allows transitions between formats as well as data validation. In PHP it was adapted as-is and released as a standalone composer library.

Drupal Contribs such as telephone_validation and telephone_formatter modules utilize said library to perform certain operations on the user input. But the problem is - we don't have a common storage where telephone could be stored in a normalized format, similar to how numbers or dates are already handled by core. With the steady growth in the usage of said modules and surpass of 10k installation I feel it's time to have better support directly in Core.

Proposed resolution

- Create a new field type plugin in the telephone module - TelephoneE164Item (telephone_e164). Allow users to choose that field type over current, simplified TelephoneItem
- Store the phone number user input AND E164 version in the database
- Create a validation constraint that will only accept the value IF user input can be represented in E164 format
- Create a formatter(s?) to show the value directly from user input, in E164 format, international or national format.

Remaining tasks

- Find out what should be the schema for the new field
- Document when the old field type should be used over the new field type (alarm numbers, vanity phone numbers, etc.

User interface changes

n/a

Introduced terminology

n/a

API changes

n/a

Data model changes

n/a

Release notes snippet

Issue fork telephone-3482705

Command icon Show commands

Start within a Git clone of the project using the version control instructions.

Or, if you do not have SSH keys set up on git.drupalcode.org:

Comments

zaporylie created an issue. See original summary.

quietone’s picture

Version: 11.0.x-dev » 11.x-dev

Changes are made on on 11.x (our main development branch) first, and are then back ported as needed according to our policies.

quietone’s picture

Version: 11.x-dev » main

Drupal core is now using the main branch as the primary development branch. New developments and disruptive changes should now be targeted to the main branch.

Read more in the announcement.

smustgrave’s picture

Status: Active » Postponed (maintainer needs more info)

So I'm not sure this will land in core as it adds additional dependencies to core to maintain.

Also there is #3266465: [policy, no patch] Remove Telephone module from core where I'm proposing telephone be removed because as you mentioned it's just a text field.

In the mean time I created https://www.drupal.org/project/telephone_e164 and if the day comes telephone gets deprecated we can move that into the contrib module.

Know it's probably not the answer you were hoping for but seem like a good compromise?

smustgrave’s picture

Status: Postponed (maintainer needs more info) » Closed (outdated)

I opted the module into security coverage and posted #3585817: Reference new telephone_e164 module so maybe it can get some attention. If telephone ever gets deprecated I'll plan to fold the two together but think this is a good alternative.

Now that this issue is closed, review the contribution record.

As a contributor, attribute any organization that helped you, or if you volunteered your own time.

Maintainers, credit people who helped resolve this issue.

zaporylie’s picture

Status: Closed (outdated) » Postponed (maintainer needs more info)

In a slack discussion about #3482705: Allow storing telephone number in E164 format catch suggested this be re-opened. He said that originally having field types in core meant people didn't have to find and download them. However, now with Project Browser and recipes those reasons are not so important.

I see this information on #3266465: [policy, no patch] Remove Telephone module from core but no reference for that conversation here or anywhere else. Any chance anyone could share that reference for posterity?

smustgrave’s picture

It was a private core channel. Think this one should remain closed as I highly doubt it landing in core with recipes now a thing.

smustgrave’s picture

Project: Drupal core » Telephone (From Core)
Version: main » 7.x-1.x-dev
Component: telephone.module » Code
Status: Postponed (maintainer needs more info) » Needs work
Issue tags: -Needs product manager review

Telephone has been deprecated so moving this issue to the contrib space

smustgrave’s picture

Version: 7.x-1.x-dev » 2.0.x-dev

Started a development branch

smustgrave’s picture

Status: Needs work » Needs review

  • smustgrave committed 499a20cb on 2.0.x
    feat: #3482705 Allow storing telephone number in E164 format
    
    By:...
smustgrave’s picture

Status: Needs review » Fixed

Lets go ahead and land this one so we can get an alpha1 out this week :)

Now that this issue is closed, review the contribution record.

As a contributor, attribute any organization that helped you, or if you volunteered your own time.

Maintainers, credit people who helped resolve this issue.