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

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
Saboteur777 opened this issue Mar 18, 2025 · 3 comments
Assignees
Labels

Comments

@Saboteur777
Copy link
Contributor

Saboteur777 commented Mar 18, 2025

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
@Saboteur777 Saboteur777 changed the title [5.x]: Multiple instances of the same entry field loads the same relation, even only one of them has it in reality [5.x]: Multiple instances of the same entry field loads the same relation, even only if one of them has it in reality Mar 18, 2025
@i-just i-just self-assigned this Mar 19, 2025
@i-just
Copy link
Contributor

i-just commented Mar 19, 2025

Hi, thanks for reporting! I raised a PR for this.

@brandonkelly
Copy link
Member

Craft 5.6.13 is out with that fix. Thanks again!

@Saboteur777
Copy link
Contributor Author

Thank you for the quick fix!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants