(I've tried this with multiple releases, including 1.6, and the issue remains).

I have a custom CTools content type (plugin), which is to be output in a panel layout being used for the homepage. The plugin configuration is using several custom form elements, all of which work fine aside from one, which is of '#type' => 'media'.

The media dialog opens over the CTools dialog (great), and I'm able to save/upload an image after going through the media upload wizard with the file being saved in the database. The Media dialog then closes, then the image's thumbnail is visible within the field as it should. However, within a second or so, a throbber appears next to the field, followed by the field disappearing all together and being replaced with: ''.

I'm assuming that this is indeed an issue with the CTools dialog, rather than the Media module. For reference, the form field's definition is below:

 $form['welcome_block_hero_image'] = array(
    '#type' => 'media',
    '#tree' => TRUE,
    '#title' => t('Hero Image'),
    '#description' => t('Allowed formats: PNG, JPG, JPEG, GIF.'),
    '#media_options' => array(
      'global' => array(
        'file_extensions' => 'png jpg jpeg gif',
        'max_filesize' => '10 MB',
        'types' => array('image'),
      ),
    ),
    '#required' => TRUE,
  );

Any info here would be great.

Thanks in advance,

Adam

Comments

adam_thomason’s picture

Not sure if this has been seen by anybody? It'd be great if somebody could give a bit of insight here.

gaborpeter’s picture

Hello Adam.
I believe we had the same issue, and adding
form_load_include($form_state, 'inc', 'your_modulename', 'your_plugin/ctools_file/path');
to the beginning of the form function ill solve this issue.

vood002’s picture

Thank you gaborpeter! I don't know why this works, but your solution worked for me. Edit: grammar

DamienMcKenna’s picture

Version: 7.x-1.6 » 7.x-1.x-dev
Component: Plugins system » Documentation
Issue tags: -#media browser javascript

That sounds like a pretty important thing to document.

darrenwh’s picture

@adam_thomason did you use hook_ctools_plugin_directory() ? I think this may be related

Albert Volkman’s picture

I attempted to use the suggested fix in #2, but to no avail. Crosslinking this issue- #2385685: Media Input is removed when using FAPI in a panel

zlatev’s picture

Hi,

Has anyone managed to debug this issue? Proposed solution in #2 is not working out for me either.

MustangGB’s picture

Priority: Critical » Normal