Problem/Motivation

In CustomWidgetBase.php we have formMultipleElements removing empty default item from field state. This works fine outside of when a custom_field is attached to a multi-valued paragraphs field. The latter scenario seems to result in the removal of the only item on paragraphs form ajax updates which leads to loss of data in the first item. It's particularly noticeably broken when one of the sub-fields is of type entity_reference with target_type media and using the media library widget but other field structures result in same undesirable behavior.

Steps to reproduce

Add a multi-valued custom_field to a paragraph type. Add a multi-value paragraph field to a node containing that type. Add a node and add a paragraph, then add a second paragraph and notice the first one's custom_field values are not preserved.

Proposed resolution

1. Set a more unique $processed_flag variable in formMultipleElements to contain the parents.
2. Add a condition to check for empty($field_state['array_parents']) before decrementing $field_state['items_count'].

Command icon Show commands

Start within a Git clone of the project using the version control instructions.

Or, if you do not have SSH keys set up on git.drupalcode.org:

Comments

apmsooner created an issue. See original summary.

apmsooner’s picture

Status: Active » Needs review
apmsooner’s picture

Issue summary: View changes

luke.leber made their first commit to this issue’s fork.

  • apmsooner committed 1f67d8c0 on 3.0.x
    Issue #3479254 by apmsooner, luke.leber: Multi-cardinality processed...
apmsooner’s picture

Status: Needs review » Fixed
apmsooner’s picture

Status: Fixed » Closed (fixed)