Problem/Motivation

When using the synonyms-enabled autocomplete field, if a tag is typed in and not matched via the dropdown list it assigns the first tag found alphabetically in the list, instead of failing with a message indicating an unknown item was entered.

Steps to reproduce

Configure a tag field to use the synonyms autocomplete field.
Make sure the "Create referenced entities if they don't already exist" option is enabled on the field.
Create a piece of content that shows the autocomplete field.
In the field, fill in a value that doesn't exist in the source, and don't select an item in the autocomplete field.
Click "Save".

What happens:
* The first possible match in the source will be added to the field.

What should happen:
* An error is shown indicating that an unknown value was entered in the field.

Proposed resolution

Fix the autocomplete field so it does not save unwanted values.

Remaining tasks

Fix the bug =)

User interface changes

The synonyms-autocomplete widget works

API changes

TBD

Data model changes

n/a

Comments

DamienMcKenna created an issue. See original summary.

damienmckenna’s picture

Assigned: Unassigned » damienmckenna

Am working on this.

damienmckenna’s picture

We'll need the changes from #3201107 for the test coverage.

devad’s picture

It would be nice to have the common free-tagging feature. The current synonyms autocomplete widget does not have it.

It is worth mentioning here that the "Create referenced entities if they don't already exist" option is never tested together with synionyms-friendly autocomplete field since it was not supposed to work. It is possible that some other errors and issues can arise as well if this option is enabled.

damienmckenna’s picture

devad’s picture

I have updated the documentation. Free-tagging warning is included now:

https://www.drupal.org/docs/contributed-modules/synonyms/submodule-synonyms-autocomplete

damienmckenna’s picture

Title: Synonyms autocomplete field assigns wrong values » Synonyms autocomplete field does not fail if unknown value entered
Issue summary: View changes
StatusFileSize
new5.29 KB

This will cause a validation error if one of the values was not found.

damienmckenna’s picture

Status: Active » Needs review
damienmckenna’s picture

StatusFileSize
new4.45 KB

Tests-only.

Status: Needs review » Needs work

The last submitted patch, 9: synonyms-n3377834-7.tests-only.patch, failed testing. View results
- codesniffer_fixes.patch Interdiff of automated coding standards fixes only.

damienmckenna’s picture

Status: Needs work » Needs review
Issue tags: -Needs tests

The tests on their own fail, while the full patch passes as expected.

damienmckenna’s picture

Assigned: damienmckenna » Unassigned

  • devad committed db066979 on 2.1.x authored by DamienMcKenna
    Issue #3377834 by DamienMcKenna: Synonyms autocomplete field does not...
devad’s picture

I tested and it works as expected for me. Committed to dev.

Note: The only change I have made before commit is that I have changed the validation Error message from: 'One of the items entered could not be found.' to: 'At least one of the items entered could not be found.' It is more general.

Thanks @DamienMcKenna.

devad’s picture

Status: Needs review » Fixed
damienmckenna’s picture

Thank you!

Status: Fixed » Closed (fixed)

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