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 am already using on a custom form a field of type 'media' without problem.
But I am not able to setup to behave as the widget on a node when you select unlimited fields.
I had try to guess combinations with no success, of 'multiple' = TRUE, attributes, cardinality, etc..
This is the working version that allow only one upload.
$form['upload_documents'] = array(
'#type' => 'media',
'#tree' => TRUE,
'#title' => t('Upload your documents'),
'#default_value' => array('fid' => $default_value),
'#media_options' => array(
'global' => array(
'file_extensions' => 'pdf doc docx',
'types' => array('document'),
),
'#attached' => array(),
'#extended' => TRUE,
'#required' => TRUE,
);
Thanks for any clue.
Comments
Comment #2
Chris Matthews CreditAttribution: Chris Matthews as a volunteer commentedClosing this issue as outdated. However, if you think this issue is still important, please let us know and we will gladly re-open it for review.
sincerely,
- the Drupal Media Team