Okay hopefully you can follow the process on this one...

I have a multi valued entity ref fields in which I use the entity reference view widget. When editing an existing node I can add new items to my field using the widget with no issue. If, however, I reorder the items and get a validation error on submitting the node form, the list of field items displayed when the form is reloaded on error is incorrect. Items are repeated twice and some may be missing completely.

I have found the cause of the bug lies in entityreference_view_widget_validate()

...
    $rows = entityreference_view_widget_rows($entity_ids, $settings);

    // Put back the rows in the form.
    drupal_array_set_nested_value($form, $form_parents, $form_existing + $rows);
...

The array union $form_existing + $rows is incorrect here as it doesn't take into account any row reordering. Instead I am thinking that array_replace should be used.

I will post a patch shortly

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

tame4tex created an issue. See original summary.

tame4tex’s picture