You are here

function claro_form_media_library_add_form_alter in Drupal 8

Same name and namespace in other branches
  1. 9 core/themes/claro/claro.theme \claro_form_media_library_add_form_alter()

Implements hook_form_BASE_FORM_ID_alter().

File

core/themes/claro/claro.theme, line 1267
Functions to support theming in the Claro theme.

Code

function claro_form_media_library_add_form_alter(array &$form, FormStateInterface $form_state) {
  $form['#attributes']['class'][] = 'media-library-add-form';
  $form['#attached']['library'][] = 'claro/media_library.theme';

  // If there are unsaved media items, apply styling classes to various parts
  // of the form.
  if (isset($form['media'])) {
    $form['#attributes']['class'][] = 'media-library-add-form--with-input';

    // Put a wrapper around the informational message above the unsaved media
    // items.
    $form['description']['#template'] = '<p class="media-library-add-form__description">{{ text }}</p>';
  }
  else {
    $form['#attributes']['class'][] = 'media-library-add-form--without-input';
  }
}