function MediaHooks::formFieldUiFieldStorageAddFormAlter

Same name and namespace in other branches
  1. 11.x core/modules/media/src/Hook/MediaHooks.php \Drupal\media\Hook\MediaHooks::formFieldUiFieldStorageAddFormAlter()

Implements hook_form_FORM_ID_alter().

Attributes

#[Hook('form_field_ui_field_storage_add_form_alter')]

File

core/modules/media/src/Hook/MediaHooks.php, line 134

Class

MediaHooks
Hook implementations for media.

Namespace

Drupal\media\Hook

Code

public function formFieldUiFieldStorageAddFormAlter(&$form, FormStateInterface $form_state, $form_id) : void {
  // Provide some help text to aid users decide whether they need a Media,
  // File, or Image reference field.
  if ($form_state->getStorage()['field_type'] === 'field_ui:entity_reference:media') {
    $form['field_options_wrapper']['description_wrapper'] = [
      '#type' => 'item',
      '#markup' => $this->fileMediaHelpText(),
    ];
  }
}

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