diff --git a/modules/eb_widget/src/Plugin/EntityBrowser/Widget/DropzoneJsEbWidget.php b/modules/eb_widget/src/Plugin/EntityBrowser/Widget/DropzoneJsEbWidget.php index 76a2947..02f8576 100644 --- a/modules/eb_widget/src/Plugin/EntityBrowser/Widget/DropzoneJsEbWidget.php +++ b/modules/eb_widget/src/Plugin/EntityBrowser/Widget/DropzoneJsEbWidget.php @@ -83,6 +83,7 @@ public static function create(ContainerInterface $container, array $configuratio */ public function defaultConfiguration() { return [ + 'dropzone_title' => $this->t('File upload'), 'upload_location' => 'public://[date:custom:Y]-[date:custom:m]', 'dropzone_description' => t('Drop files here to upload them'), 'max_filesize' => file_upload_max_size() / pow(Bytes::KILOBYTE, 2) . 'M', @@ -90,21 +91,58 @@ public function defaultConfiguration() { ] + parent::defaultConfiguration(); } + /** + * {@inheritdoc} + */ + public function buildConfigurationForm(array $form, FormStateInterface $form_state) { + $config = $this->getConfiguration(); + + $form['dropzone_title'] = [ + '#type' => 'textfield', + '#title' => $this->t('Dropzone label'), + '#default_value' => $config['settings']['dropzone_title'], + ]; + $form['upload_location'] = [ + '#type' => 'textfield', + '#title' => $this->t('Upload location'), + '#default_value' => $config['settings']['upload_location'], + ]; + $form['dropzone_description'] = [ + '#type' => 'textarea', + '#title' => $this->t('Dropzone description'), + '#default_value' => $config['settings']['dropzone_description'], + ]; + $form['max_filesize'] = [ + '#type' => 'textfield', + '#title' => $this->t('Maximum file size'), + '#default_value' => $config['settings']['max_filesize'], + ]; + $form['extensions'] = [ + '#type' => 'textfield', + '#title' => $this->t('Allowed extensions'), + '#required' => TRUE, + '#default_value' => $config['settings']['extensions'], + ]; + return $form; + } + /** * {@inheritdoc} */ public function getForm(array &$original_form, FormStateInterface $form_state, array $aditional_widget_parameters) { $config = $this->getConfiguration(); $form['upload'] = [ - '#title' => t('File upload'), '#type' => 'dropzonejs', '#required' => TRUE, '#dropzone_description' => $config['settings']['dropzone_description'], '#max_filesize' => $config['settings']['max_filesize'], '#extensions' => $config['settings']['extensions'], ]; + if (!empty($config['settings']['dropzone_title'])) { + $form['upload']['#title'] = $config['settings']['dropzone_title']; + } - // Disable the submit button until the upload sucesfully completed. + // Disable the submit button until the upload successfully completes. $form['#attached']['library'][] = 'dropzonejs_eb_widget/common'; $original_form['#attributes']['class'][] = 'dropzonejs-disable-submit';