function umami_form_alter

Same name in other branches
  1. 10 core/profiles/demo_umami/themes/umami/umami.theme \umami_form_alter()
  2. 11.x 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

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';
        }
    }
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.