Reusing an existing field imports its conditional fields

Created on 11 October 2023, about 1 year ago
Updated 18 August 2024, 4 months ago

Problem/Motivation

In Drupal 9/10, when you create a new content type and reuse an existing field that have a condition, it will attached its dependency (conditional fields) as well.

I used a Drupal 10 latest, fresh install of the Umami demo to reproduce the bug.

The conditional fields from content type A should not be shown on content type B when we reuse a field!

Steps to reproduce

Example taken on the Umami demo site:

Content type A: Recipe
Add a a conditional field (Manage dependencies tab):
SHOW field_cooking_time WHEN field_difficulty EQUAL "Medium"

Content type B: Article
1) Click on Manage Fields
2) Click on Re-use an existing field
3) Reuse field_cooking_time and save the field.
4) Click on Manage dependencies (Article content type).

You can see the existing conditional field from Recipe have been imported.
Hover over the Edit button, and you can see that the URL path relates to the Recipe content type, not the Article content type.

This means our field cooking time will not be visible on our ARTICLE CT, because the condition won't be met (field_difficulty is not present on ARTICLE CT)

If we delete the dependency from the ARTICLE content type, it send you back to the RECIPE content type and delete the dependency there.

If you delete the dependency from the RECIPE content type, and got back to the ARTICLE content type, you can see that the dependency is still showing, but clicking on edit or delete will have no effect because it does not exists anymore.

This seems to be a hude issue.

Proposed resolution

When reusing an existing field, its dependencies should not be copied.

Thank you

πŸ› Bug report
Status

Active

Version

4.0

Component

Code

Created by

πŸ‡¦πŸ‡ΊAustralia zebrapuddingrainfall

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

Comments & Activities

Production build 0.71.5 2024