summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAnkur Rishi2005-08-23 23:08:23 (GMT)
committer Ankur Rishi2005-08-23 23:08:23 (GMT)
commit8262835653fb5b569b67ae4f30fe5509bb90c539 (patch)
tree931678fe08fd26b3753c43c86154b2d1acdf9d67
parent413bf0f3e6eca2a37883cc4cc7e8fc5e06949260 (diff)
Adding in validation for (province, country) pairs as requested by Robert Douglass
in http://drupal.org/node/25457
-rw-r--r--location.module14
1 files changed, 14 insertions, 0 deletions
diff --git a/location.module b/location.module
index e610367..ed6dec2 100644
--- a/location.module
+++ b/location.module
@@ -289,6 +289,20 @@ function location_nodeapi(&$node, $op, $teaser = NULL, $page = NULL) {
}
$node->location[$field_name] = trim($node->location[$field_name]);
}
+
+ // Check if the (province, country) pair is valid
+ if (isset($node->location['province']) && !empty($node->location['province']) && $node->location['province'] != 'xx' &&
+ isset($node->location['country']) && !empty($node->location['country']) && $node->location['country'] != 'xx') {
+ $province_list_function = 'location_province_list_'. $node->location['country'];
+ if (function_exists($province_list_function)) {
+ $translated_location = location_form2api($node->location);
+ if (!in_array($translated_location['province'], array_keys($province_list_function()))) {
+ form_set_error('location][province', t('Please make sure to select a state/province from the country you have selected.'));
+ }
+ }
+ }
+
+ // Check if submitted lat/lon are valid
if (user_access('submit latitude/longitude')) {
if ((!strlen(trim($node->location['latitude'])) && strlen(trim($node->location['longitude']))) ||
(strlen(trim($node->location['latitude'])) && !strlen(trim($node->location['longitude'])))) {