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.
Hi,
I'm trying to use the plupload field in a custom module. At the moment i try to figure out how to set the '#default_value'
. Let's say i have an validation error on some other field in the same form and the whole form rebuilds on submit. I would like to keep the files (or temporary files) in the plupload filed so user's don't need to re-upload in case of form validation errors.
On form submit i get data as follow in $form_state['input']
:
I couldn't find anything about default values in the modules code itself.
Comment | File | Size | Author |
---|---|---|---|
Screen Shot 2015-08-14 at 11.21.53.png | 241.46 KB | N20 |
Comments
Comment #2
slashrsm CreditAttribution: slashrsm as a volunteer commentedThere is no support for #default_value at the moment. I am not sure how #default_value would be expected to work with plupload. Custom forms should take care of files that were already uploaded and make sure they somehow get stored in case of validation fails.
How exactly would #default_value work if we decide to add this feature?
Comment #3
N20 CreditAttribution: N20 commented'#default_value' could probably work like the core image field. I'm not sure how it is managed in the core field but i guess it deals with the files that are in tmp.
Comment #4
slashrsm CreditAttribution: slashrsm commentedField widget (what core image field widget is) and form API element (what Plupload element is) are two different things. If you use Plupload with one of the modules (see Plupload project page) that provide field widget around it you get similar experience that is provided by core widget.