I'm getting the following error after I create or edit a record. The formatting appears to work properly apart from this.

Notice: Undefined offset: 5 in format_gb_phone_number() (line 122 of /home/billboar/public_html/bcf2/sites/all/modules/phone/include/phone.gb.inc).
Notice: Undefined offset: 8 in format_gb_phone_number() (line 122 of /home/billboar/public_html/bcf2/sites/all/modules/phone/include/phone.gb.inc).
Notice: Undefined offset: 6 in format_gb_phone_number() (line 123 of /home/billboar/public_html/bcf2/sites/all/modules/phone/include/phone.gb.inc).
Notice: Undefined offset: 9 in format_gb_phone_number() (line 123 of /home/billboar/public_html/bcf2/sites/all/modules/phone/include/phone.gb.inc).
Notice: Undefined offset: 7 in format_gb_phone_number() (line 123 of /home/billboar/public_html/bcf2/sites/all/modules/phone/include/phone.gb.inc).
Notice: Undefined offset: 10 in format_gb_phone_number() (line 123 of /home/billboar/public_html/bcf2/sites/all/modules/phone/include/phone.gb.inc).
Notice: Undefined offset: 12 in format_gb_phone_number() (line 124 of /home/billboar/public_html/bcf2/sites/all/modules/phone/include/phone.gb.inc).

Comments

mrpauldriver’s picture

I should say also that the messages only appear when the field is populated

wipeout_dude’s picture

Seems to appear when there are spaces in the phone number (which are added as part of the formatting)..

mrpauldriver’s picture

I haven't tested that, but it would be pretty inadequate if it was the case. The whole point of such a module is to correctly format the number, however entered!

I am wanting this module to correctly apply iPhone (dial) formatting, which can be sometimes be lost if the number is outputted by Views.

dddbbb’s picture

Status: Closed (duplicate) » Active

I'm getting the exact same errors when trying to save a phone number to a field.

annikaC’s picture

I get this too.

rar’s picture

Has this module been abandoned? I just discovered the same issue when the US phone number isn't perfectly formatted (e.g. if you type 12345 for a phone number you get

Notice: Undefined offset: 2 in format_ca_phone_number() (line 75 of modules/phone/include/phone.ca.inc).
Notice: Undefined offset: 3 in format_ca_phone_number() (line 77 of modules/phone/include/phone.ca.inc).
Notice: Undefined offset: 4 in format_ca_phone_number() (line 77 of modules/phone/include/phone.ca.inc).
Notice: Undefined offset: 5 in format_ca_phone_number() (line 80 of modules/phone/include/phone.ca.inc).

But it looks like the last commit on this module was nearly 6 months ago.

jessico’s picture

I'm getting a similar message when entering anything beyond valid numbers with no spaces.

Example: 6025555555 is correctly submitted to the system and is properly formatted.

60255555554444 causes an undefined error.
602 555 5555 causes an undefined error.
sadfasdfasdfas causes an undefined error.

This is the error I am receiving:

Notice: Undefined index: message in field_default_form_errors() (line 381 of /var/www/drupal/modules/field/field.form.inc).

Any ideas on how to modify the module to create our own error messages in these cases?

g1smd’s picture

I have completely rewritten the CCK Phone GB module.

It did not correctly format many UK numbers and didn't cope with several types of numbers.

See separate issue for it.

mrpauldriver’s picture

Thank you .

Having read the issue at http://drupal.org/node/1728312 it looks as if you have taken a very thorough approach. Who would have thought it was so complicated?

g1smd’s picture

It is very complicated, and there are many ways to approach the problem. RexEx patterns are key to making this easier.

Most people try to validate the input in multiple ways in a single RegEx pattern: format, length and area code validity. This is doomed to failure. Additionally, many of the RegEx patterns used here are very inefficient. In particular, common data in an OR should not be repeated, i.e (^0....$|^0....$|^0....$) simplifies to ^0(....|....|....)$ making the pattern easier to read from left to right.

The new approach is to split the validation and formatting into multiple tasks. Let the user enter the number in almost any way they like. Why penalise the user that typed (00 44) (0) 2030 005 555 instead of 020 3000 5555 or +44 20 3000 5555?

Don't try to validate the whole number in a single operation. Strip out the prefix and make a note whether international or national format is required. Store any extension for later use. Validate the NSN part is the right length to be valid and is in a valid range. Format the NSN part using rules based on length and range, then separately add on the requisite prefix and any extension number data.

I've rewritten all of the various country files to some extent, and will post them here over the next few weeks as each is tested.

mrpauldriver’s picture

Has the GB formatting been rolled in to dev as yet?

g1smd’s picture

Not that I know of.

I've stopped work on the other modules for now, pending action being taken on those already submitted.

slcp’s picture

Status: Active » Closed (duplicate)

I am closing this as a duplicate of #1728312: CCK Phone GB - Complete rewrite of code..

Having tested and put into use the re-write undertaken by g1smd in the above issue I am confident that is a well thought out and robust approach, which does eliminate the problems reported in this issue.

Please take time to test the patch in this issue so we can get it RTBC.

g1smd’s picture

Thanks!

inventlogic’s picture

Updated to the latest dev and the error message I am getting when saving a node is:

Notice: Undefined offset: 8 in format_gb_phone_number() (line 122 of /var/virtualsites/rpcb/html/sites/all/modules/phone/include/phone.gb.inc). => 

This is repeated several times so seems to be the same problem as reported on January 1, 2012.

Looks like the patch in https://drupal.org/node/1728312 has not been applied due to an attribution dispute.

Last updated on November 9, 2012 at 6:55pm must be time to move on and get things done.

Can we apply the patch as its really annoying to get these messages every time I save a node with a UK telephone number?

Status: Active » Closed (duplicate)
james.williams’s picture

Issue summary: View changes
StatusFileSize
new1019 bytes

The attached patch deals with the notices, for anyone still using 7.x-1.x without the work done in #1728312: CCK Phone GB - Complete rewrite of code..

james.williams’s picture

StatusFileSize
new1019 bytes

Sorry, that patch left one notice remaining. Try this one :-)