FieldType extension for normalized storage

Created on 7 November 2018, over 5 years ago
Updated 22 November 2023, 7 months ago

Hello,

I'm on a project that is looking to add telephone_formatter as a dependency. Your formatter is great, but we need a widget to normalize the format of phone numbers stored in a telephone field.

Has there been talk/plans of adding a widget to this project?

Thanks!

✨ Feature request
Status

Needs work

Version

2.0

Component

Code

Created by

πŸ‡¨πŸ‡¦Canada Nils Loewen Kelowna, BC

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

  • πŸ‡¦πŸ‡ΊAustralia ELC

    A different approach - I kept the setting in the same theme as the rest of the validation settings; each field can have its storage format set regardless of the widget used for input. Unfortunately had to use hook_entity_presave to alter the value prior to save. I assume there is a better way to hook in to alter the value other than creating a new field plugin. Perhaps decorate or replace the class. Open to suggestion.

    Optionally saves in PhoneNumberFormat::E164, PhoneNumberFormat::NATIONAL or untouched input. Digits only would be National format. Can obviously shoot yourself in the foot by saving a pile of E164 input numbers as National and make them useless.

    Having completed this different approach, I think this should be in a different module as it doesn't line up with the rest of the functionality of the module. The code could be almost the same in that module, using the same trigger settings inside telephone_validation and piggy backing the same forms.

    In an ideal world, the Drupal Telephone field would store the number in E164 + format identifier (a-la datetime with timezone) always and then the form widget and field display would be configurable. Stored data consistency being the key - at present the phone field can be nearly anything in any layout the inputing user chooses.

Production build 0.69.0 2024