You are here

public function MediaEntityDropzoneJsEbWidget::buildConfigurationForm in DropzoneJS 8.2

Same name and namespace in other branches
  1. 8 modules/eb_widget/src/Plugin/EntityBrowser/Widget/MediaEntityDropzoneJsEbWidget.php \Drupal\dropzonejs_eb_widget\Plugin\EntityBrowser\Widget\MediaEntityDropzoneJsEbWidget::buildConfigurationForm()

Overrides DropzoneJsEbWidget::buildConfigurationForm

1 call to MediaEntityDropzoneJsEbWidget::buildConfigurationForm()
InlineEntityFormMediaWidget::buildConfigurationForm in modules/eb_widget/src/Plugin/EntityBrowser/Widget/InlineEntityFormMediaWidget.php
1 method overrides MediaEntityDropzoneJsEbWidget::buildConfigurationForm()
InlineEntityFormMediaWidget::buildConfigurationForm in modules/eb_widget/src/Plugin/EntityBrowser/Widget/InlineEntityFormMediaWidget.php

File

modules/eb_widget/src/Plugin/EntityBrowser/Widget/MediaEntityDropzoneJsEbWidget.php, line 78

Class

MediaEntityDropzoneJsEbWidget
Provides an Entity Browser widget that uploads media entities.

Namespace

Drupal\dropzonejs_eb_widget\Plugin\EntityBrowser\Widget

Code

public function buildConfigurationForm(array $form, FormStateInterface $form_state) {
  $form = parent::buildConfigurationForm($form, $form_state);
  $form['media_type'] = [
    '#type' => 'select',
    '#title' => $this
      ->t('Media type'),
    '#required' => TRUE,
    '#description' => $this
      ->t('The type of media entity to create from the uploaded file(s).'),
  ];
  $media_type = $this
    ->getType();
  if ($media_type) {
    $form['media_type']['#default_value'] = $media_type
      ->id();
  }
  $media_types = $this->entityTypeManager
    ->getStorage('media_type')
    ->loadMultiple();
  if (!empty($media_types)) {
    foreach ($media_types as $media_type) {
      $form['media_type']['#options'][$media_type
        ->id()] = $media_type
        ->label();
    }
  }
  else {
    $form['media_type']['#disabled'] = TRUE;
    $form['media_type']['#description'] = $this
      ->t('You must @create_media_type before using this widget.', [
      '@create_media_type' => Link::createFromRoute($this
        ->t('create a media type'), 'media.add')
        ->toString(),
    ]);
  }

  // Remove these config options as these are propagated from the field.
  $form['max_filesize']['#access'] = FALSE;
  $form['extensions']['#access'] = FALSE;
  $form['upload_location']['#access'] = FALSE;
  return $form;
}