You are here

public function BulkUploadForm::buildForm in Lightning Media 8

Same name and namespace in other branches
  1. 8.4 modules/lightning_media_bulk_upload/src/Form/BulkUploadForm.php \Drupal\lightning_media_bulk_upload\Form\BulkUploadForm::buildForm()
  2. 8.2 modules/lightning_media_bulk_upload/src/Form/BulkUploadForm.php \Drupal\lightning_media_bulk_upload\Form\BulkUploadForm::buildForm()
  3. 8.3 modules/lightning_media_bulk_upload/src/Form/BulkUploadForm.php \Drupal\lightning_media_bulk_upload\Form\BulkUploadForm::buildForm()

Form constructor.

Parameters

array $form: An associative array containing the structure of the form.

\Drupal\Core\Form\FormStateInterface $form_state: The current state of the form.

Return value

array The form structure.

Overrides FormInterface::buildForm

File

modules/lightning_media_bulk_upload/src/Form/BulkUploadForm.php, line 70

Class

BulkUploadForm
A form for uploading multiple media assets at once.

Namespace

Drupal\lightning_media_bulk_upload\Form

Code

public function buildForm(array $form, FormStateInterface $form_state) {
  $extensions = $this->helper
    ->getFileExtensions(TRUE);
  $form['dropzone'] = [
    '#type' => 'dropzonejs',
    '#dropzone_description' => $this
      ->t('Drag files here to upload them'),
    '#extensions' => implode(' ', $extensions),
  ];
  $form['continue'] = [
    '#type' => 'submit',
    '#value' => $this
      ->t('Continue'),
  ];
  $variables = [
    '@max_size' => static::bytesToString(file_upload_max_size()),
    '@extensions' => Element::oxford($extensions),
  ];
  $form['dropzone']['#description'] = $this
    ->t('You can upload as many files as you like. Each file can be up to @max_size in size. The following file extensions are accepted: @extensions', $variables);
  return $form;
}