Translation breaks if using different cardinality

Created on 24 July 2025, 8 days ago

Problem/Motivation

Was getting random whitescreens when editing translated content using a partially-translated custom field.

Error: Attempt to assign property "subfieldname" on null in Drupal\custom_field\Plugin\Field\FieldType\CustomItem->preSave() (line 205 of .../custom_field/src/Plugin/Field/FieldType/CustomItem.php).

Steps to reproduce

Set up translation.
Add a custom_field to a translatable node type.
Make it Unlimited values cardinality.
Add 2 subfields.
Configure the translation for the node type to include the custom field as translatable.
Configure the custom field, making one of the subfields translatable but not the other.
Edit a piece of content. Set no values for the custom field.
Translate the piece of content, set a value on the translated version.
Return to the untranslated version of the content. Add multiple values to the custom field.

At some point in this process, you'll get the error listed above when saving the node.

Proposed resolution

Don't assume we have the same number of values on translated content and untranslated content for our field.

Remaining tasks

User interface changes

API changes

Data model changes

πŸ› Bug report
Status

Active

Version

3.1

Component

Code

Created by

πŸ‡ΊπŸ‡ΈUnited States gcb

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Merge Requests

Comments & Activities

Production build 0.71.5 2024