Problem/Motivation
During work on #2409701: Field storage configuration is not exposed to config translation UI, a bug with translation of "sequence" data types was discovered.
Exported translated configuration looked like this:
settings:
allowed_values:
label: string1
1:
label: string2
While it was expected to look like this:
settings:
allowed_values:
-
label: string1
-
label: string2
Bug source
In \Drupal\config_translation\FormElement\ListElement::setConfig()
, the following string creates the element ID appending the element key to the base key (which may be not provided, so NULL).
$element_key = implode('.', array_filter(array($base_key, $key)));
The problem is that for sequences, the key could be "0", so it's filtered by the array_filter() function.
Proposed resolution
Change the code to:
$element_key = ltrim("$base_key.$key", '.');
Remaining tasks
+ create patch
- write tests
User interface changes
none
API changes
none
Comment | File | Size | Author |
---|---|---|---|
#1 | drupal8-sequence_translation-2413481-1.patch | 1.42 KB | Leksat |
Comments
Comment #1
Leksat CreditAttribution: Leksat commentedNo tests yet.
Comment #2
Schnitzel CreditAttribution: Schnitzel commentedtagging
Comment #3
Schnitzel CreditAttribution: Schnitzel commentedComment #4
tstoecklerThanks for reporting this! Unfortunately you are not the first to hit this problem...
This is a duplicate of #2395627: Do not remove 0 from config translation data. That one has tests, but I like the ltrim() approach here better than the one used there. That one introduces a separate method for this, though, which I think makes sense. Maybe we can just merge the two patches?