Same name and namespace in other branches
  1. 8.9.x core/modules/filter/src/Element/TextFormat.php \Drupal\filter\Element\TextFormat::accessDeniedCallback()
  2. 9 core/modules/filter/src/Element/TextFormat.php \Drupal\filter\Element\TextFormat::accessDeniedCallback()

Render API callback: Hides the field value of 'text_format' elements.

To not break form processing and previews if a user does not have access to a stored text format, the expanded form elements in \Drupal\filter\Element\TextFormat::processFormat() are forced to take over the stored #default_values for 'value' and 'format'. However, to prevent the unfiltered, original #value from being displayed to the user, we replace it with a friendly notice here.

Parameters

array $element: The render array to add the access denied message to.

Return value

array The updated render array.

File

core/modules/filter/src/Element/TextFormat.php, line 280

Class

TextFormat

Namespace

Drupal\filter\Element

Code

public static function accessDeniedCallback(array $element) {
  $element['#value'] = t('This field has been disabled because you do not have sufficient permissions to edit it.');
  return $element;
}