Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
I have found a problem that when more than one instance of dropzonejs field is added to a single form, only the first one is properly initiated.
The second one has no functionality attached.
Steps to reproduce:
1. Create a new custom form
2. Add dropzonejs field twice, e.g.
$form['dropzonejs_first'] = [
'#title' => t('DropzoneJs element'),
'#type' => 'dropzonejs',
'#required' => TRUE,
'#dropzone_description' => 'DropzoneJs description',
'#max_filesize' => '1M',
'#extensions' => 'jpg png',
];
$form['dropzonejs_second'] = [
'#title' => t('DropzoneJs element'),
'#type' => 'dropzonejs',
'#required' => TRUE,
'#dropzone_description' => 'DropzoneJs description',
'#max_filesize' => '1M',
'#extensions' => 'jpg png',
];
3. Only first instance of the field is initiated, the second one has to behaviours attached.
Comment | File | Size | Author |
---|---|---|---|
#3 | cannot_instantiate-2798543-3.patch | 6.42 KB | chr.fritsch |
Comments
Comment #2
Primsi CreditAttribution: Primsi at MD Systems GmbH commentedComment #3
chr.fritschNot sure if this is all, but it seems to work
Comment #4
Andrew211 CreditAttribution: Andrew211 commentedThanks @chr.fritsch works a treat, uploaded 2 years ago and still not "8.x-2.0-alpha3 released 14 December 2017", bizarre.
Comment #5
SocialNicheGuru CreditAttribution: SocialNicheGuru commentedAre these duplicates of one another?
https://www.drupal.org/project/dropzonejs/issues/3011067
Comment #6
idebr CreditAttribution: idebr at iO commentedYep, I closed the related issue as a duplicate.
Comment #7
FirstSanny CreditAttribution: FirstSanny commentedWorks like a charm. Thanks a lot. You saved me a lot of trouble.
Tested with Drupal core 8.6.3 and dropzonejs 8.x-2.0-alpha3.
Comment #8
genellann CreditAttribution: genellann commentedWhich patch should I use? The one from this thread, #3 by chr.fritsch, or the one from the duplicate bug thread, #2 by idebr?
Comment #9
genellann CreditAttribution: genellann commentedThis patch (#3 by chr.fritsch) worked for me. The other (#2 by idebr on dup) did not work.
Comment #10
ainarend CreditAttribution: ainarend commentedCan confirm that the patch #3 resolves the issue.
Comment #11
chr.fritschMoving to 2.x
Comment #12
chr.fritschSetting to RTBC based on #7, #9 and #10
Comment #14
chr.fritschFixed
Comment #16
Joe HuggansThank you for this, absolute lifesavers.
Comment #17
Joe HuggansI believe I have found a bug with this, albeit an edge case.
If you upload 2 files with the same filename, one of each into 2 dropzones, then the second dropzone field is empty when looking at the $form_state