When you try to reference an entity with a slash in its title, the autocomplete search only uses the characters before the slash when finding matches.

This is a problem because it breaks the expected behavior that being more specific in your autocomplete search will yield more specific and refined results. It's especially a problem when you have more than 10 entities with very similar titles. In some cases, the autocomplete field will never show the specific entity that you want even if you type in the entire title, because it's knocked off the results list by the other 10 similar titles.

For example: II.1, II.2, II.3, ..., II.10, II/III.1 <-- last one won't show

The problem is due to the way search strings are tacked onto the end of the autocomplete URL. If there are slashes in the search string, Drupal's menu system assumes there are more arguments at the end of the URL.

The taxonomy module solves this problem for its autocomplete term reference fields by explicitly piecing the search string back together from any arguments at the end of the URL.

CommentFileSizeAuthor
#1 entityreference-slashes-2012314.patch3.13 KBaasarava

Comments

aasarava’s picture

Status: Active » Needs review
StatusFileSize
new3.13 KB

And here's a patch. This mostly copies the simple solution in taxonomy.module. The patch also includes updated tests.

amitaibu’s picture

Status: Needs review » Fixed

Committed, thanks.

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.