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

pedrosp created an issue. See original summary.

Chris Matthews’s picture

Status: Active » Closed (outdated)

Closing 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