When you set an Entity Reference field settings to "Entity selection" -> "Views: Filter by an entity reference view" the results returned by the view can be formatted and styled by Views to include HTML tags and line breaks. This gets removed by the inline_entity_form_autocomplete() function.
By changing this code:
foreach ($results as $result) {
// Strip things like starting/trailing white spaces, line breaks and tags.
$result = str_replace("\n", '', trim(decode_entities(strip_tags($result))));
$matches[$result] = '<div class="reference-autocomplete">' . $result . '</div>';
}
To this:
foreach ($results as $result) {
// Strip things like starting/trailing white spaces, line breaks and tags.
$result_index = str_replace("\n", '', trim(decode_entities(strip_tags($result))));
$matches[$result_index] = '<div class="reference-autocomplete">' . $result . '</div>';
}
The formatting by Views can be preserved in the result list.
Patch to follow.
| Comment | File | Size | Author |
|---|---|---|---|
| #1 | ief_autocomplete-perserve-tags_2118841-01.patch | 786 bytes | bendiy |
Comments
Comment #1
bendiy commentedSee attached patch.
Comment #2
bojanz commentedYou are right.
Used $key as the variable name and added the preg_match so that it matches the entityreference code.
Committed:
http://drupalcode.org/project/inline_entity_form.git/commitdiff/2e574ef?...