You are here

function umami_form_alter in Drupal 10

Same name and namespace in other branches
  1. 9 core/profiles/demo_umami/themes/umami/umami.theme \umami_form_alter()

Implements hook_form_alter().

@todo revisit in https://drupal.org/node/3110132

File

core/profiles/demo_umami/themes/umami/umami.theme, line 127
Functions to support theming in the Umami theme.

Code

function umami_form_alter(array &$form, FormStateInterface $form_state, $form_id) {
  $form_object = $form_state
    ->getFormObject();
  if ($form_object instanceof ViewsForm && strpos($form_object
    ->getBaseFormId(), 'views_form_media_library') === 0) {

    // The conditional below exists because the media-library-views-form class
    // is currently added by Classy, but Umami will eventually not use Classy as
    // a base theme.
    // @todo remove conditional, keep class addition in
    //   https://drupal.org/node/3110137
    // @see https://www.drupal.org/node/3109287
    // @see classy_form_alter()
    if (!isset($form['#attributes']['class']) || !in_array('media-library-views-form', $form['#attributes']['class'])) {
      $form['#attributes']['class'][] = 'media-library-views-form';
    }
  }
}