This issue is part of meta issue #1931088: [META] Fixing tests

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.

CommentFileSizeAuthor
location.views_.patch1.71 KBjhedstrom

Comments

summit’s picture

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

hypertext200’s picture


// $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

hypertext200’s picture

Status: Needs review » Reviewed & tested by the community
podarok’s picture

Status: Reviewed & tested by the community » Postponed

postponed before tests fix
#1931088: [META] Fixing tests

podarok’s picture

Status: Postponed » Needs review

tests fixed #1931088: [META] Fixing tests
lets go

Status: Needs review » Needs work

The last submitted patch, location.views_.patch, failed testing.

Anonymous’s picture

Issue summary: View changes

Updated issue summary.

legolasbo’s picture

Issue summary: View changes
Status: Needs work » Closed (outdated)

Closing old D6 issues as D6 is end of life