Using ajax "add another" field when updating field values (f.e. adding multiple taxonomy terms) and clicking add another item doesn't work.

Visually the page updates and a second item is added, but it's value is never submitted. Trying to add more than two items doesn't work either. It seems that the max_delta never gets added to when setting a breakpoing in the ajax submit callback method, and the value from the second item doesn't get added to the values array for the form.

Removing the call to $form_state->disableCache() in ModifyEntityValues::buildConfigrationForm (ModifyEntityValues.php:155) fixes the issue, but I assume this isn't a real solution to the problem but may serve as a start off point for further debugging.

Comments

kevineinarsson created an issue. See original summary.

kevineinarsson’s picture

StatusFileSize
new620 bytes

Attached a patch for us using Composer, note that the issue still needs work and this patch might (will) break other things.

kevineinarsson’s picture

Issue summary: View changes
jmagunia’s picture

When I clicked Add Another for an Entity Reference field it wouldn’t add additional inputs nor would it record any changes beyond the first input.

When I added a Form View and changed the entity reference from AutoComplete to Checkboxes it worked.

Adding a Correct form view is described in this module’s Readme.

chr.fritsch’s picture

Status: Needs work » Needs review
StatusFileSize
new537 bytes

Rerolled the patch.

This patch is currently the same like in #3181221: Disabled cache on ModifyEntityValues form prevents paragraphs "remove" button to work. Let's trigger the tests.

chr.fritsch’s picture

I found out that the media_library widget is also not working without this fix.

@graber: Can you recall what the problem was why the cache was disabled?

chr.fritsch’s picture

Status: Needs review » Reviewed & tested by the community

I found out this was introduced in #2974237: Serialization exception when trying to edit a file/image field. It was about adding multiple images to an article in one edit step. So I tested it again with 3 images fields on a node, with different cardinalities and uploaded multiple images to every field. Everything went smoothly.

So I think it is save remove it.

chr.fritsch’s picture

In #3181221: Disabled cache on ModifyEntityValues form prevents paragraphs "remove" button to work @pmate also said that he couldn't find any issues with file fields without the disabled cache.

@graber: Please credit @pmate in this issue.

pmate’s picture

Just wanted to say thanks for moving this through! Big thanks!

graber’s picture

Yes, let's try it, worst case we'll end up with the file issue reopened after the next release.

  • Graber committed f96bf81 on 8.x-2.x authored by chr.fritsch
    Issue #3094414 by kevineinarsson, chr.fritsch: "Add Another" AJAX...
graber’s picture

Status: Reviewed & tested by the community » Fixed

Status: Fixed » Closed (fixed)

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