function claro_form_alter

Same name in other branches
  1. 9 core/themes/claro/claro.theme \claro_form_alter()
  2. 10 core/themes/claro/claro.theme \claro_form_alter()
  3. 11.x core/themes/claro/claro.theme \claro_form_alter()

Implements hook_form_alter().

File

core/themes/claro/claro.theme, line 362

Code

function claro_form_alter(array &$form, FormStateInterface $form_state, $form_id) {
    $build_info = $form_state->getBuildInfo();
    $form_object = $form_state->getFormObject();
    // Make entity forms delete link use the action-link component.
    if (isset($form['actions']['delete']['#type']) && $form['actions']['delete']['#type'] === 'link' && !empty($build_info['callback_object']) && $build_info['callback_object'] instanceof EntityForm) {
        $form['actions']['delete'] = _claro_convert_link_to_action_link($form['actions']['delete'], 'trash', 'default', 'danger');
    }
    if ($form_object instanceof ViewsForm && strpos($form_object->getBaseFormId(), 'views_form_media_library') === 0) {
        if (isset($form['header'])) {
            $form['header']['#attributes']['class'][] = 'media-library-views-form__header';
            $form['header']['media_bulk_form']['#attributes']['class'][] = 'media-library-views-form__bulk_form';
        }
        $form['actions']['submit']['#attributes']['class'] = [
            'media-library-select',
        ];
    }
}

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