- Issue created by @mtalt
- @mtalt opened merge request.
- Issue was unassigned.
- Status changed to Needs review
about 1 year ago 6:44pm 6 June 2023
When creating a new entity, the default domain value(s) for the bundle are not being set.
The first issue is that the default value of the field is overridden by the active domain. This change was introduced in this issue β with this change in the hook_field_widget_form_alter..
Domain Access does have logic to set the default value to the current domain, but only does so if the field is required.
The second issue is that the default domain values are not being set properly because the array returned by the third party setting is keyed with strings instead of numerically. In Drupal Core's FieldInputValueNormalizerTrait::normalizeValue method, if the keys are not numeric, it will re-key all values under the 0 key. That results in only 1 of the selected default domains being set.
To solve the first issue, I propose that checks are added to only populate the value of the field if the field is required and no default value has already been set.
The second issue can be solved by using numerical array keys when setting the default value.
A MR has been created.
Needs review
Code