Media 2.0 module can be used to replace file selection/upload for Image fields or WYSIWYG image inserts and it all works great. (So far nothing with this module...)

When editing a content that has an image field with Media, you click 'Browse' for the model window to open. Once the window is open you 1) Upload a new file 2) populate it's fields 3) Save the file - this closes the model window and attaches the saved file to the image field.

Here is the Inline Entity Form bug with this workflow: We add an entity reference field to the File Entity type (Image). If this entity reference field is using Inline Entity Form (Single or Multiple) on the image file, the media workflow breaks. After clicking Save on step 3 above, instead of the image getting selected and attached to the Image field, we are taken to /admin/content/file inside the model window and the workflow ends. If the same entity reference field is NOT using Inline Entity Form, it works fine.

Seems like the form action, or destination action of the form is altered somehow by using the inline entity form widget... Maybe it has to do with Inline Entity Form replacing the parent form's action?

Thanks!
Sia

Comments

adam-delaney’s picture

@Siavash I have ran into this problem as well and it creates a big problem for our project.

For now I have unset the action submit items in a form_alter. My concern with the approach is that we are ignoring these callbacks (inline_entity_form_trigger_submit, file_entity_add_upload_submit). I have done some basic testing and it appears that everything is working as expected. I'm wondering if this isn't a problem because when the entire form gets submitted: file_entity_add_upload_submit takes care of everything.

Any suggestions or recommendations would be appreciated.

Here is my code:

// Bypass inline-entity forms default actions if we are uploading via media.
  // Scope to media-popup.
  if (isset($form['#options']['render']) && $form['#options']['render'] == 'media-popup') {
    // Scope file_entity or web source uploads i.e. youtube.
    if ($form_id == 'file_entity_add_upload' || $form_id == 'media_internet_add_upload') {
      // Unset inline-entity forms actions.
      unset($form['actions']['submit']['#submit']);
    }
  }