Default file widget functionality. File is uploaded, remove button is added to the page as well. I'm sure that code is running because i'm able to debug it upon ajax upload. Still no new class, no wrapper element in response.

function mytheme_preprocess_file_widget_multiple(&$variables) {
  if ($variables['element']['#field_name'] == 'field_my_field') {
    foreach (Drupal\Core\Render\Element::children($variables['element']) as $key) {
      $variables['element'][$key]['remove_button']['#attributes']['class'][] = 'remove-button';
      $variables['element'][$key]['remove_button']['#prefix'] = '<span class="remove-button>';
      $variables['element'][$key]['remove_button']['#suffix'] = '</span>';

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.