If you select spanish format, the module doesn't work because the regexp is wrong. I had change the regexp and now works with +xx xxx xxx xxx format and xxx xxx xxx format.

Attach the patch file.

Members fund testing for the Drupal project. Drupal Association Learn more

Comments

javiferrer’s picture

Sorry, the previous patch has a mistake. Attach the correct patch.

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.

syp’s picture

Status: Closed (fixed) » Needs review

Still this problem isn't solved in dev release.
Confirmed this patch works, but with a minor issue:
When no international code is entered, a space is inserted at the beginning of the phone number.
Ex: " 699 699 699"
I solved it this way:

function format_es_phone_number($phonenumber, $field = FALSE) {

  // define regular expression
  $regex = '/
   	\D*                  # optional separator
   	(\+[0-9]{2})?        # optional international code
   	\D*                  # optional separator
   	(\d{3})              # first number group
   	\D*                  # optional separator
   	(\d{3})              # second number group
   	\D*                  # optional separator
   	(\d{3})              # third number group
    $/x';
  
  // get digits of phone number
  preg_match($regex, $phonenumber, $matches);

  // construct ten-digit phone number
  if(strlen($matches[1])>0)
	$phonenumber = $matches[1] . ' ' . $matches[2] . ' ' . $matches[3] . ' ' . $matches[4];
  else
	$phonenumber = $matches[2] . ' ' . $matches[3] . ' ' . $matches[4];
  return $phonenumber;
}

(Sorry I don't have a development site to create a patch)

warmth’s picture

After applying this patch is needed this other: #1026708: Spanish phone CCK field removes content

Is this patch going to be committed?

warmth’s picture

Priority: Normal » Major

Guys why did you release a new version without fixing this?

cweagans’s picture

Priority: Major » Normal

What do you mean? We haven't released a new version.

rfsbsb is the new comaintainer of this module's 1.x branches. He was just given commit access a week or two ago. Please standby.

warmth’s picture

Few days ago I was prompted to update the module and this fix was not included. That's all I mean.

Edgar Saumell’s picture

Assigned: javiferrer » Unassigned
Priority: Normal » Critical

FYI: With 7.x-1.x-dev - 2013-May-25 I get this error:
Notice: Undefined offset: 3 in format_es_phone_number() (line 69 of .../sites/all/modules/phone/include/phone.es.inc).

Didn't tried any patches here.

cweagans’s picture

Priority: Critical » Normal
Issue summary: View changes

Resetting priority. This isn't critical.

sja1’s picture

# 3 worked for me, and I did not have to apply patch mentioned in #4.

And I would say it is a critical bug. All attemps to save a Spanish phone number throw an error.

For me this meant that I was unable to update any nodes that had a Spanish phone number field, as this field generates an error on save every time.

jlbellido’s picture

Update #1 patch with the sugested code in #3, this patch works for me and i didn't apply the patch mentioned in #4.

This should be critical because, phone numbers isn't saving.

Thanks to @javiferrer and @syp for their work.

jlbellido’s picture

FileSize
2.63 KB

Added the interdiff of the previous patch, sorry for noise.

reallifedigital’s picture

Patch in #11 working for me.

milopca’s picture

Patch in #11 working for me too.