I have a Canadian phone number field with the "Add the country code if not filled by the user" option selected. When a number without a country code is entered, the country code is prefixed to the field. But when a country code is provided, the country code is removed.

In format_ca_phone_number, a valid entered country code is never added to $phonenumber.

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

pbuyle’s picture

The attached patch preprend the country code extracted from the input. The country code is validated and will have to be 1 if provided. If the "_Add the country code if not filled by the user_", the country code is prepended only if not already provided.

pbuyle’s picture

A space is needed after the country code.

pbuyle’s picture

I should test my patch before hitting submit...

pbuyle’s picture

Issue summary: View changes
Status: Active » Needs review
drclaw’s picture

I can confirm that the patch performs as advertised. Thanks! :)