The problem that we were having is as follows:

We are using this module on a user sign up page and we want the location settings to be optional. However when submitting the page without entering any location information it was returning the error:
The latitude must be a number
The longitude must be a number

when looking in the code for the module we discovered what we believe to be a bug.

from line 281 to 294 in gcg.module looks like this

if (isset($form['#value']['latitude'])) {
    if (!is_numeric($form['#value']['latitude'])) {
      form_error($form['latitude'], t('The Latitude must be a number.'));
    } else if ($form['#value']['latitude'] < -90 || $form['#value']['latitude'] > 90) {
      form_error($form['latitude'], t('The Latitude must be between -90&deg; and 90&deg;'));
    }
  }
  if (isset($form['#value']['longitude'])) {
    if (!is_numeric($form['#value']['longitude'])) {
      form_error($form['longitude'], t('The Longitude must be a number.'));
    } else if ($form['#value']['longitude'] < -180 || $form['#value']['longitude'] > 180) {
      form_error($form['longitude'], t('The Longitude must be between -180&deg; and 180&deg;'));
    }
  }

essentially the 'isset' was identifying that something had been set however that 'something' was 'nothing' (whilst not being NULL)
so the module was thinking that something had been set but was identifying that the 'something' was not numeric and therefore returning the error.

we replaced the isset with !empty and it is now working fine:

if (!empty($form['#value']['latitude'])) {
if (!is_numeric($form['#value']['latitude'])) {
form_error($form['latitude'], t('The Latitude must be a number.'));
} else if ($form['#value']['latitude'] < -90 || $form['#value']['latitude'] > 90) {
form_error($form['latitude'], t('The Latitude must be between -90&deg; and 90&deg;'));
}
}
if (!empty($form['#value']['longitude'])) {
if (!is_numeric($form['#value']['longitude'])) {
form_error($form['longitude'], t('The Longitude must be a number.'));
} else if ($form['#value']['longitude'] < -180 || $form['#value']['longitude'] > 180) {
form_error($form['longitude'], t('The Longitude must be between -180&deg; and 180&deg;'));
}
}

I have attached a patch.

Files: 
CommentFileSizeAuthor
gcg_longitude_must_be_a_number.patch1.03 KBsonictruth

Comments

bdragon’s picture

Status:Active» Fixed

Whoops, I guess this is the original issue. Fixed as per the commit mentioned in #283391: GCG-enabled node types don't allow empty location (which is actually closer to your patch, heh)

Anonymous’s picture

Status:Fixed» Closed (fixed)

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