For some reason on a lot of my products the images are empty when editing using inline entity form, while on others they are not empty. This happens even though there is an existing image.

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

mglaman’s picture

Project: Commerce Kickstart » Inline Entity Form
Version: 7.x-2.x-dev » 7.x-1.x-dev

Confirmed, it is an issue with...

    // Attach fields.
    $langcode = entity_language('commerce_product', $product);
    field_attach_form('commerce_product', $product, $entity_form, $form_state, $langcode);

on a multilingual site. If there is a check for $langcode being empty and setting it as LANGUAGE_NONE; it fixes the issue. For some reason the Image field doesn't populate properly on the entity edit form unless $langcode is explicitly set.

Moving this to inline_entity_form, patch to follow.

mglaman’s picture

Apply a fallback to set language code to undefined if entity_language empty

mglaman’s picture

Status: Active » Needs review
lsolesen’s picture

Status: Needs review » Reviewed & tested by the community

I can confirm that this works.

msamavi’s picture

The same issue here, but the patch did not work for me!

bojanz’s picture

Status: Reviewed & tested by the community » Needs review
Issue tags: +commerce-sprint

This looks like a revert of #1558632: Pass correct langcode to field_attach_form, newly created entities. which means we need more research on which one's correct.

energee’s picture

The above patch does not include a fix on the default entity form.

energee’s picture

Status: Needs review » Needs work

The last submitted patch, 8: 2224915-images-empty-when-editing-products-using-ief-8.patch, failed testing.

The last submitted patch, 8: 2224915-images-empty-when-editing-products-using-ief-8.patch, failed testing.

smccabe’s picture

Status: Needs work » Needs review

Status: Needs review » Needs work

The last submitted patch, 8: 2224915-images-empty-when-editing-products-using-ief-8.patch, failed testing.

mattew’s picture

Got the same issue with a custom entity (not a commerce product) and this patch solved the issue for me. The images are now visible in my field using IEF, FYI here is a summary of my setup:

  1. the field with IEF widget is translatable through Entity Translation
  2. the entity referenced by IEF is not translatable (my strategy: different entities per language)
  3. the IEF widget is the "Single value" one
  4. my entity type has been created using Entity Scaffold module.

Would you like me to test something more on my implementation?

Thanks for the patch

matthiasm11’s picture

Patch #9 from the referenced issue solves this problem at a higher level, with entity translation support instead of hardcoded LANGUAGE_NONE.

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.