Commit edbc6875 authored by phenaproxima's avatar phenaproxima Committed by Primsi
Browse files

Issue #2724113 by phenaproxima: Dropzone elements should set a default maximum file size

parent a0b198ad
......@@ -76,6 +76,10 @@ class DropzoneJs extends FormElement {
'#attributes' => ['data-upload-path' => \Drupal::url('dropzonejs.upload')],
];
if (empty($element['#max_filesize'])) {
$element['#max_filesize'] = file_upload_max_size();
}
if (!\Drupal::currentUser()->hasPermission('dropzone upload files')) {
$element['#access'] = FALSE;
drupal_set_message("You don't have sufficent permissions to use the DropzoneJS uploader. Contact your system administrator", 'warning');
......
......@@ -42,7 +42,7 @@ class DropzoneJsElementTest extends KernelTestBase {
$form = \Drupal::formBuilder()->getForm('\Drupal\dropzonejs_test\Form\DropzoneJsTestForm');
$this->render($form);
$xpath_base = "/html/body/form/div[contains(@class, 'form-item-dropzonejs')]";
$xpath_base = "//div[contains(@class, 'form-item-dropzonejs')]";
// Label.
$this->assertFalse($this->xpath("$xpath_base/label[text()='Not DropzoneJs element']"));
$this->assertTrue($this->xpath("$xpath_base/label[text()='DropzoneJs element']"));
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment