template_preprocess_file_managed_file

template_preprocess_file_managed_file(&$variables)

Prepares variables for file form widget templates.

Default template: file-managed-file.html.twig.

Parameters

array $variables: An associative array containing:

  • element: A render element representing the file.

File

core/modules/file/file.module, line 1220
Defines a "managed_file" Form API field and a "file" field for Field module.

Code

1
2
3
4
5
6
7
8
9
10
11
function template_preprocess_file_managed_file(&$variables) {
  $element = $variables['element'];
 
  $variables['attributes'] = array();
  if (isset($element['#id'])) {
    $variables['attributes']['id'] = $element['#id'];
  }
  if (!empty($element['#attributes']['class'])) {
    $variables['attributes']['class'] = (array) $element['#attributes']['class'];
  }
}
doc_Drupal
2025-01-10 15:47:30
Comments
Leave a Comment

Please login to continue.