function ThemeHooks::textFormat
Same name and namespace in other branches
- 11.x core/themes/admin/src/Hook/ThemeHooks.php \Drupal\admin\Hook\ThemeHooks::textFormat()
Prerender callback for text_format elements.
File
-
core/
themes/ admin/ src/ Hook/ ThemeHooks.php, line 401
Class
- ThemeHooks
- Provides theme related hook implementations.
Namespace
Drupal\admin\HookCode
public static function textFormat(array $element) : array {
// Add clearfix for filter wrapper.
$element['format']['#attributes']['class'][] = 'clearfix';
// Hide format select label visually.
$element['format']['format']['#wrapper_attributes']['class'][] = 'form-item--editor-format';
$element['format']['format']['#attributes']['class'][] = 'form-element--extrasmall';
$element['format']['format']['#attributes']['class'][] = 'form-element--editor-format';
// Fix JS inconsistencies of the 'text_textarea_with_summary' widgets.
// @todo Remove when https://www.drupal.org/node/3016343 is fixed.
if (!empty($element['summary']) && $element['summary']['#type'] === 'textarea') {
$element['#attributes']['class'][] = 'js-text-format-wrapper';
$element['value']['#wrapper_attributes']['class'][] = 'js-form-type-textarea';
}
if (!empty($element['#description']) && \Drupal::classResolver(Settings::class)->get('show_description_toggle') && Helper::isContentForm()) {
if ($element['#type'] === 'text_format') {
$element['value']['#description_toggle'] = TRUE;
}
else {
$element['#description_toggle'] = TRUE;
$element['#description_display'] = 'invisible';
}
}
return $element;
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.