I have a custom form created with Form API. In this form, I have a file field with the type managed_file
$form['fichiers_justificatif'] = array(
'#type' => 'managed_file',
'#title' => 'justificatifs',
'#upload_validators' => $validators,
'#upload_location' => 'private://justificatifs',
'#multiple' => TRUE,
'#description' => 'types de fichier autorisés : png gif jpg jpeg pdf doc',
);
It works well, I can upload a file, get its name and url.
But I don’t know how to have a multiple file upload like the one with see in admin or with the webform module.
Example of webform module which handle multiple files upload :
I’ve tried to add '#multiple' => TRUE
, but I have an Ajax error after the 2nd file is submitted.
I’ve tried this module Multi-value form element but still have AJAX issue.
I’ve tried dropzone.js but I'm not satisfied with it since it adds an other interface for file (different from the one in admin). User are confused there is an other interface for files.
What could be the better way to handle this ?
#multiple
works, at least for these 6 people who, like me, upvoted this answer drupal.stackexchange.com/a/226326/47547. Could be a conflict with other Ajax code on your site.#multiple
works. I will try to debug my AJAX issue then. In my form, I uses some custom services and I see in the Ajax error that the 2nd file cause an Ajax call to those services which initially works. My issue seems to be related to this issue.#multiple works
, I was able to debug the Ajax issue. The answer that helps me : drupal.stackexchange.com/questions/212928/… (useprotected
instead ofprivate
for my custom services).