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
Comment | File | Size | Author |
---|---|---|---|
#2 | entityreference_view_widget-fix_validation_array_bug-2555693.patch | 673 bytes | tame4tex |
Comments
Comment #2
tame4tex CreditAttribution: tame4tex commented