Hi,

Autocomplete reference removes " from previous labels, so the value is broken after it. I have fixed it. Patch attached.

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

brtamas created an issue. See original summary.

othermachines’s picture

Status: Needs review » Reviewed & tested by the community

Patch still applies on 7.x-1.x-dev and appears to be a straightforward fix.

To reproduce

Note: This applies to any referenced labels (such as node titles), not just terms.

Test terms:

  • apple "banana"
  • orange

Autocomplete (tags style) widget behaviour:

Typing in apple "banana", orange and clicking on the provided suggestions results in this value:

apple "banana" (1), orange (2)


Submitting results in the following error:

There are no entities matching "apple".

With the patch applied, the final value of the autocomplete looks like:

"apple ""banana"" (1)", orange (2)

The submit is successful with the correct terms applied.

othermachines’s picture

Issue summary: View changes
Status: Reviewed & tested by the community » Needs review
Related issues: +#2185003: Cannot add referenced entities that have commas or double quotes in title. Field widget autocomplete (tag style)

Interesting... this patch seems to resolve issues with commas within values as well as quotes. See related issue #2185003: Cannot add referenced entities that have commas or double quotes in title. Field widget autocomplete (tag style).

Reverting back to Needs Review in hopes we can get some testers from over there.

dgtlmoon’s picture

Status: Needs review » Needs work

Could you add a test for this? does it apply to 1.x?

othermachines’s picture

Version: 7.x-1.1 » 7.x-1.x-dev

Thought it was worth noting that 8.x uses EntityAutocomplete::getEntityLabels() which basically does the same thing as drupal_implode_tags() (if you strip out the non-applicable stuff like autocreate).

This seems pretty straightforward to me but if a test is needed maybe there's something in 8.x to draw inspiration from. If @brtamas isn't interested I'll have a go but I might not get to it for a week or two.