- 🇦🇺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.