Ina bug was introduced that incorrectly translates the label of multi-value fields twice:
$header = array( array( - 'data' => '<h4 class="label">' . t('!title !required', array('!title' => $element['#title'], '!required' => $required)) . "</h4>", + 'data' => array( + '#prefix' => '<h4 class="label">', + 'title' => array( + '#markup' => t($element['#title']), + ), + '#suffix' => '</h4>', + ), 'colspan' => 2, 'class' => array('field-label'), ),
$element['#title'] value is already translated at this stage:
- As translated string, in the case of config fields
TranslatableMarkupin the case of base fields
This provides a wrong translation in the first case and throw an
InvalidArgumentException in the 2nd case.
- Remove the
- Remove also the 'title' wrapping of #markup item. That seems superfluous.
- Add test.
User interface changes
Data model changes
Original report, by @ChristianAdamski
the issue described here is probaby more widespread than just the scenario. I therefor assume there already is an issue for this, I just couldn't find any
- define an entity reference BaseFieldDefinition in a custom entity
- Use entity_reference_autocomplete
- use setLabel(t("Hello World")); as done across core
- allow more than one entry
- WSOD when trying to edit
In template_preprocess_field_multiple_value_form() in line 1580 you'll find
'#markup' => t($element['#title']),
but $element['#title'] already contains translatableMarkup. I do not know what happens afterwards, as the result is also translatableMarkup, but it is different and results in WSOD.
Remove the t(), the field label is already translated at this point.