Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
By joachim on
Change record status:
Published (View all published change records)
Project:
Introduced in branch:
8.x
Issue links:
Description:
The 'label' property in hook_field_extra_fields() is no longer sanitized on output. It is now the responsibility of implementations of hook_field_extra_fields() to sanitize this string themselves.
This allows modules to use t() with placeholders in the label for extra fields.
Before:
foreach (node_type_get_types() as $bundle) {
if ($bundle->has_title) {
$extra['node'][$bundle->type]['form']['title'] = array(
'label' => $bundle->title_label,
'description' => $description,
'weight' => -5,
);
}
}
After:
foreach (node_type_get_types() as $bundle) {
if ($bundle->has_title) {
$extra['node'][$bundle->type]['form']['title'] = array(
'label' => t('Yay for labels - my label is: %label', array('%label' => $bundle->title_label)),
'description' => $description,
'weight' => -5,
);
}
}
Note that if the label is not created by new FormattableMarkup()
or t()
it will be autoescaped by Twig.
Impacts:
Module developers