I'm creating a custom form and using the media field as defined in hook_element_info of the media module. I'm running into an issue when adding more than one media field to my form because the #process callback for media form fields create an fid field with the same name for every media field on the page. You will alway only get the last fid value on the submitted form.

Comments

tom friedhof’s picture

I tinkered with the #process function media_element_process() and renamed the fid element to $element["#name"] .'_fid', but that broke thinks with the fields widget. I ended up defining my own #process function (copying the media module function verbatim with the exception of that one field) in my own module for the media field and handled unique names specifically for the form I'm working within.

$element[$element['#name'] .'_fid'] = array(
    '#type' => 'textfield',
    '#default_value' => $fid,
    '#attributes' => array('class' => array('fid')),
);

Any ideas on how to get this change to work in media.module and still have it work with field api widgets?

chris matthews’s picture

Issue summary: View changes
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