Hi,

Ran into a problem when using Inline Entity Form module to edit an existing entity with entity_reference_multiple field value filled in already.

The target type value is not set correctly in entity_reference_multiple_field_widget_form() in the above situation during the IEF ajax callback due to $form_state['values'] not containing relevant values.

Patch included to verify target_type within form_state values.

Thanks,
Kevin

Comments

khu’s picture

zestagio’s picture

Hello,
Need re-test on latest version. I can't reproduce after fixing some code. If you're still experiencing problems, please provide the way how to reproduce a bug

ACF’s picture

Status: Needs review » Reviewed & tested by the community

I can confirm that this problem exists and the patch in #1 fixes it.

To reproduce:

Add field to any entity.

Use inline entity form to create instance of that entity, filling in the entity reference multiple field.

Edit the entity and the entity type is empty, which will then mean that the field will be cleared on save.

I'm not going to commit another version of the patch but the only thing I'd change is

$key_exists = NULL;
$nested_value = drupal_array_get_nested_value($form_state['values'], $parents, $key_exists);
if ($key_exists) {
   $target_type_value = $nested_value;
}

to

$nested_value = drupal_array_get_nested_value($form_state['values'], $parents, $key_exists);
if ($key_exists) {
   $target_type_value = $nested_value;
}

As you shouldn't need to set a default.