Skip to content

[5.x]: Multiple instances of the same entry field loads the same relation, even only if one of them has it in reality #16912

@Saboteur777

Description

@Saboteur777

What happened?

Description

On a multisite (5 sites for 5 different languages) Craft install I created an Entry field, called relatedAutomaticProcess. I added two instances of it to my Products entry type: lastGetProductsProcess and lastTranslateProductsProcess:

color: null
fieldLayouts:
  2b6966f2-7b86-40a3-8e1e-a21757e874c5:
  [...]
        elements:
          -
            dateAdded: '2025-03-18T14:14:55+00:00'
            elementCondition: null
            fieldUid: 694a1a3c-3804-4481-b905-1035021028d5 # Related Automatic Process
            handle: lastGetProductsProcess
            includeInCards: false
            instructions: null
            label: 'Last getProducts Process'
            providesThumbs: false
            required: false
            tip: null
            type: craft\fieldlayoutelements\CustomField
            uid: 58012a82-8cd1-4090-be3c-ec3c467df0fe
            userCondition: null
            warning: null
            width: 25
          -
            dateAdded: '2025-03-18T14:14:55+00:00'
            elementCondition: null
            fieldUid: 694a1a3c-3804-4481-b905-1035021028d5 # Related Automatic Process
            handle: lastTranslateProductsProcess
            includeInCards: false
            instructions: null
            label: 'Last translateProducts Process'
            providesThumbs: false
            required: false
            tip: null
            type: craft\fieldlayoutelements\CustomField
            uid: 46f4c747-761b-44e1-afd3-ea41813dbc46
            userCondition: null
            warning: null
            width: 25
[...]

I save a relation into one of them with the following code:

$entry->lastTranslateProductsProcess = [$automaticProcessEntry->id];

Craft::$app->elements->saveElement($entry);

When viewing this on the "primary" site, everything looks fine:

Image

If I switch to a different site, both fields have the same relation:

Image

The fields are not translatable, while the section propagates its entries to all sites.

Steps to reproduce

  1. Create an Entry field.
  2. Add multiple instance of it to an entry type.
  3. Save relation into one of the instances programmatically.

Expected behavior

Show related entry only in the field where it belongs.

Craft CMS version

5.6.11

PHP version

8.2.27

Operating system and version

Linux 6.6.80-1-MANJARO

Database type and version

MySQL 8.0.41

Image driver and version

Imagick 3.7.0 (ImageMagick 7.1.1-41)

Installed plugins and versions

  • CKEditor 4.6.0
  • Postmark 3.1.0

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions