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.

Comments

bendiy’s picture

Status: Active » Needs review
StatusFileSize
new786 bytes

See attached patch.

bojanz’s picture

Issue summary: View changes
Status: Needs review » Fixed

You 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?...

Status: Fixed » Closed (fixed)

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