function MediaLibraryHooks::formAlter

Implements hook_form_alter().

File

core/modules/media_library/src/Hook/MediaLibraryHooks.php, line 192

Class

MediaLibraryHooks
Hook implementations for media_library.

Namespace

Drupal\media_library\Hook

Code

public function formAlter(array &$form, FormStateInterface $form_state, $form_id) : void {
    // Add a process callback to ensure that the media library view's exposed
    // filters submit button is not moved to the modal dialog's button area.
    if ($form_id === 'views_exposed_form' && str_starts_with($form['#id'], 'views-exposed-form-media-library-widget')) {
        $form['#after_build'][] = '_media_library_views_form_media_library_after_build';
    }
    // Configures media_library displays when a type is submitted.
    if ($form_state->getFormObject() instanceof MediaTypeForm) {
        $form['actions']['submit']['#submit'][] = '_media_library_media_type_form_submit';
        // @see field_ui_form_alter()
        if (isset($form['actions']['save_continue'])) {
            $form['actions']['save_continue']['#submit'][] = '_media_library_media_type_form_submit';
        }
    }
}

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