I have a fairly complex setup with panels and ctools with a custom module that implements a ctools panels plugin. The plugin contains a Media element that works fine under 7.x-2.0-alpha3 but is currently broken in 7.x.2.x-dev. The Browse button launches the Media Browser and you can successfully pick the media, but after clicking Submit, the dialog closes, there is a brief flash where you see the thumbnail of the item selected and then it is removed from the page.

It appears the culprit is related to media_ajax_upload() which calls drupal_process_form(). As far as I can tell, the appropriate form_id, form and form state are passed to drupal_process_form() but the form that returns doesn't contain the Media element in question, and is thus removed.

I'm hoping that there were just some changes, yet-to-be-documented, in dev that mean I need to call it differently in this particular situation. Here is the functioning code under alpha-3:

$form['image'] = array(
    '#type' => 'media',
    '#title' => t('Trigger Image'),
    '#default_value' => $conf['image'],
  );

Is there something else I need to do when in the ctools panels plugin context?

As far as I can tell, the Media element is operating correctly everywhere else including /media/browser/testbed.

Comments

pauloamgomes’s picture

Same issue here, but if if you try to inject the form field in a hook_form_alter() it will work, media element not removed (but isn't a valid solution).

Albert Volkman’s picture

I'm experiencing this issue as well... I know this issue is a bit old. Did either of you find a better solution?

Chris Matthews’s picture

Status: Active » Closed (outdated)

Recent versions of media have resolved most of peoples concerns and is compatible with entity translation, multilingual and various advanced configurations. Due to the high volume of inactive and most often irrelevant issues we are Closing this as (outdated). If for whatever reason this issue is important to you AND you still have issues after checking the media recipe documentation, then let us know and we will review your concerns.

Otherwise, see the recipe documentation for how to configure media and for troubleshooting tips OR refer to the media_dev distribution if you want to see a working media setup.

As mentioned, feel free to make some noise in this issue if you still feel it is important to you or someone else.

Thanks,

Media team