Translating an entity with the "Conditions" field removes the value of the "Conditions" field from the original entity

Created on 12 November 2024, about 1 month ago

Translating an entity with a "Condition" field, which is displayed with commerce_conditions form widget, removes the "Condition" field value from the original entity.

Step to reproduce:

  1. Enable the "Content Translation" and "Commerce Promotion" modules
  2. Add any secondary language
  3. Enable translating for the "Promotion" entity type and "Hide non translatable fields on translation forms" for it on the /admin/config/regional/content-language page
  4. Create a new Promotion entity (all fields should be filled)
  5. Add translation for this entity
  6. The conditions field is wiped

The problem here is related to the \Drupal\commerce\Element\Conditions form element, which is used for the "Conditions" non-translatable field. This form element has \Drupal\commerce\Element\Conditions::submitConditions method that is called during form validation and is responsible for generating an associative array of enabled conditions of only visible children elements. But our "Conditions" field is hidden with $element['#access'] = FALSE and therefore the "Conditions" field is wiped for the original entity after saving the translation.

🐛 Bug report
Status

Active

Version

2.0

Component

Commerce

Created by

🇺🇦Ukraine chizh273

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