I try to filter selective on countries that come from Address Field Module but I can't get it to work with the full country names. If I check off the country fields "Display the localized country name instead of the two character country code" the selective filter works. Otherwise the dropdown list is populated correctly with the countries that are in the result set, but after clicking "Apply" there are no more results.

I have tried to rewrite the output of the the country field used by the selective filter but this just shows the rewrite pattern itself like [replacement] so many times like the results. The filter nevertheless works that way too.

Is there something i overlooked or is this a common restriction?

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

Valera Tumash’s picture

I have exact same issue. In addition when you change the url from ?field_address_country_selective=Australia to ?field_address_country_selective=AU it will work.

Any updates on this thread?

drupal_sh’s picture

Valera, I have the same issue too. Were you able to find a workaround to get this to work?

iampuma’s picture

In the selective handler file retrieving the key with the get_value() function is not working correctly for select fields.

$key = $display_field_handler->get_value($row);

The patch will retrieve the value directly through the field alias, afterwards go further with get_value() if a value is not found.

iampuma’s picture

Status: Active » Needs review
iampuma’s picture

Updated to check for an array or object instead.

jerry’s picture

Version: 7.x-1.3 » 7.x-1.x-dev
FileSize
1.74 KB

Attaching an updated version of the patch above to limit the field alias to 60 characters, as is apparently required.

herved’s picture

I got the same issue today.
Indeed it seems field aliases are limited to 60 chars in \views_plugin_query_default::add_field().
The patch in #6 looks good to me and is working well.

Thank you everyone ;)

petr.hajek’s picture

#5 Worked for me. (I haven't tested #6)
Thanks.

michael_wojcik’s picture

Status: Needs review » Reviewed & tested by the community

Ran into the same issue with Country and State (AKA Administrative Area) fields from the Address Field module.

Patch from #6 worked perfectly for me.

Marking this issue as "Reviewed & tested by the community". Patch from #6 should be ready to be ported, pending the module maintainer's approval.

david_garcia’s picture

Status: Reviewed & tested by the community » Needs work

I've been looking into this and it looks as though there are 2 different issues here. One related to alias length and the other I'm still not sure what to.

I've opened a separate issue for the truncated alias problem.

#2743873: Field aliases are limited to 60 characters

As for the original report in this issue regarding address field, and the implemented solution, I'd like to see an explanation as to why this:

$key = $row->{$field_alias};

Has priority over:

$key = $display_field_handler->get_value($row);

When the original implementation was the other way round.

david_garcia’s picture

BTW, before RTBC an issue ensure that a proper summary template has been used and filled in the description:

https://www.drupal.org/issue-summaries

Thanks!

david_garcia’s picture

glynster’s picture

I have applied views_selective_filters-select_list_key_fix-2504309-6.patch and addressfield now works successfully with selective view filter. I am using the latest version of views_selective_filter. RTBC +1

ochic’s picture

#6 works for me with 7.x-1.5, but I cannot apply the patch with dev version.

achikas’s picture

great patch. would be nice to see it in the next version.

bohemier’s picture

#6 works for me as well... RTBC as well

NWOM’s picture

#6 still works great. Thank you!

glynster’s picture

FileSize
1.55 KB

Rereolled #6 to work with latest dev version and 7.x-1.6