Posted by jhedstrom on May 27, 2009 at 6:38pm
Jump to:
| Project: | Location |
| Version: | 6.x-3.x-dev |
| Component: | Location_views |
| Category: | feature request |
| Priority: | normal |
| Assigned: | Unassigned |
| Status: | reviewed & tested by the community |
Issue Summary
The attached patch adds a views plugin for argument validation for provinces. It works now, but only for the US...it would probably be beneficial to add a form that allowed a user to pick countries to validate against.
| Attachment | Size |
|---|---|
| location.views_.patch | 1.71 KB |
Comments
#1
Hi, This would be great to have for the selected country and not only for the US, would that be possible please?
Thanks a lot in advance for considering.
greetings,
Martijn
#2
<?php
// $Id$
/**
* @file
* Views plugin to validate province arguments for the location
* module.
*/
class views_plugin_argument_validate_province extends views_plugin_argument_validate {
function validate_argument($argument) {
if (isset($this->view->argument['country'])) {
$country = $this->view->argument['country']->argument;
} else {
$country = variable_get('location_default_country', 'us');
}
// Validate that province exists.
$provinces = location_get_provinces($country);
if ($argument) {
if (!in_array(strtoupper($argument), array_keys($provinces)) && !in_array($argument, array_values($provinces))) {
return FALSE;
}
}
return TRUE;
}
}
?>
Add this to your views_plugin_argument_validate_province.inc
#3