I'm looking for a way to upload many files by means of the managed_file
form API element. I would like it be like while uploading for node where is 'add new item' button.
How to do it?
-
What is managed_file field. Is it a field you created.– 15dk51Commented Jul 11, 2013 at 7:06
-
It's #type from Drupal Form API. I want to do it by code.– deemCommented Jul 11, 2013 at 7:08
-
If it's about Form API, it's not a "field", it's a "form element" - these terms have very specific meaning. So, if I read you right, you should remove tag fields and add form-api. And of course edit content to replace word "field".– MołotCommented Jul 11, 2013 at 7:11
Add a comment
|
2 Answers
You may want to use plupload form element instead. Install Plupload integration module and then use something like:
$form['my_element'] = array(
'#type' => 'plupload',
'#title' => t('Upload files'),
'#description' => t('This multi-upload widget uses Plupload library.'),
'#upload_validators' => array(
'file_validate_extensions' => array('jpg jpeg gif png txt doc xls pdf ppt pps odt ods odp'),
'my_custom_file_validator' => array('some validation criteria'),
),
'#plupload_settings' => array(
'runtimes' => 'html5',
'chunk_size' => '1mb',
),
);
-
I installed it and there is only info like "This multi-upload widget uses Plupload library. Allowed file types: jpg jpeg gif png txt doc xls pdf ppt pps odt ods odp."– deemCommented Jul 11, 2013 at 9:24
-
-
Paths issue, however I would like to use the managed_file type.– deemCommented Jul 11, 2013 at 11:09
-
@daroPL Sadly, there is no "managed_files" type, just "managed_file".– MołotCommented Jul 11, 2013 at 11:11
-
I had a look on
file_field_widget_form()
and there it is done it bymanage_file
.– deemCommented Jul 11, 2013 at 11:29