When the location Country field is added as an exposed filter in a View, the "Force single" option is selected, and a default value is given, the resulting query returns no rows. In my case, I have the default value set to USA. If I hit the view with no parameters, no rows are returned, despite USA being selected by default in the exposed filter. When I click the filter Submit button, the resulting query is fine.

I have tracked this down to location_handler_filter_location_country.inc's query() method lines 66-73. When "Force Single" is selected, $this->values looks like array( 0 => 'us' ).. when Force Single is not selected, $this->values looks like array( 'us' => 'us' ).. thus, these lines end up putting 'country='0'' in the sql query when Force Single is engaged.

I'm going to see if I can't figure out a solution to this.. will post a patch.

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

reubenavery’s picture

Status: Active » Needs review
FileSize
822 bytes

Here's my patch.. seems to work, hope I'm not missing something!

YesCT’s picture

I missed this earlier. Adding tags.

might not be related, but might be: #730730: Default country location should not be 'us' but blank

rooby’s picture

Status: Needs review » Closed (duplicate)

This problem has been fixed in this issue #467412: Cannot Select Particular Countries for Views Location Filter

If you get the latest dev the problem should be gone.

Marking this issue as a duplicate.

anithagutta_a’s picture

FileSize
177.43 KB

Profile Location Countries list optins is Not Showing up in Exposed Views filteres. help me