We have a view set up with a separate field that displays the autocomplete data in a certain format. But we found that if you search with special characters such as apostrophes, the autocomplete seems to return no results.
I tracked it down to Line 132 of views_autocomplete_filters.inc
. That line is as follows:
if (isset($item['value']) && strstr(drupal_strtolower($item['value']), drupal_strtolower($string))) {
First, I'm not sure why this line is here. I mean, if you search a view for $string
, it should only return results with $string
's value, right? But this line seems to just verify that the items actually do have this text in the value.
In my case, $item['value']
contains the HTML encoded version of $string
, so they didn't match. Therefore, I modified it to this and it now works:
if (isset($item['value']) && strstr(decode_entities(drupal_strtolower($item['value'])), drupal_strtolower($string))) {
If it even makes sense to have this check for some reason I don't see, it seems helpful to add decode_entities()
to make sure these things can match.
Thanks!