Come together with the global Drupal community in Rotterdam, 28 Sept – 1 Oct 2026. Sessions, contribution, connection, and Early Bird savings until 8 June.
Same problem. Neither drag-and-drop nor manually entered row weights are saved - it seems to default to the order in which items were added, beginning with 0, 1, 2 and so on.
I'm having the same issue. Noticed that order is saved if you click "edit" or "add" variation and then cancel (or save). So something is missing to trigger the save when you just reorder the variations... I've spent hours and hours going through the code but can't find the right angle...
Well, I'm not sure what the heck I'm doing. But it does seem to work well if you put the delta loop before the "abort validation" code like thus (row 699 of inline_entity_form.module):
// Loop over the submitted delta values and update the weight of the entities
// in the form state.
foreach (element_children($element['entities']) as $key) {
$form_state['inline_entity_form'][$parents_key]['entities'][$key]['weight'] = $element['entities'][$key]['delta']['#value'];
}
// Abort validation if the form has been rebuilt by an unknown element, such
// as a field widget inside the embedded form.
if (!in_array($triggering_element_name, array_keys(inline_entity_form_widget_form_actions()))) {
return;
}
// Abort validation if the triggering element doesn't share parents with the
// current element (which means that the event came from another IEF widget).
$triggering_parents = array_slice($form_state['triggering_element']['#array_parents'], 0, count($parents));
if ($parents != $triggering_parents) {
return;
}
original code was (row 699-716 of inline_entity_form.module) :
// Abort validation if the form has been rebuilt by an unknown element, such
// as a field widget inside the embedded form.
if (!in_array($triggering_element_name, array_keys(inline_entity_form_widget_form_actions()))) {
return;
}
// Abort validation if the triggering element doesn't share parents with the
// current element (which means that the event came from another IEF widget).
$triggering_parents = array_slice($form_state['triggering_element']['#array_parents'], 0, count($parents));
if ($parents != $triggering_parents) {
return;
}
// Loop over the submitted delta values and update the weight of the entities
// in the form state.
foreach (element_children($element['entities']) as $key) {
$form_state['inline_entity_form'][$parents_key]['entities'][$key]['weight'] = $element['entities'][$key]['delta']['#value'];
}
I guess one of the maintainers should look at the consequences of doing this. But it fixes the problem although it could have other repercussions I'm not aware of.
Comments
Comment #1
lastar84 commentedSame problem. Neither drag-and-drop nor manually entered row weights are saved - it seems to default to the order in which items were added, beginning with 0, 1, 2 and so on.
Comment #2
leanderl commentedI'm having the same issue. Noticed that order is saved if you click "edit" or "add" variation and then cancel (or save). So something is missing to trigger the save when you just reorder the variations... I've spent hours and hours going through the code but can't find the right angle...
Comment #3
leanderl commentedWell, I'm not sure what the heck I'm doing. But it does seem to work well if you put the delta loop before the "abort validation" code like thus (row 699 of inline_entity_form.module):
original code was (row 699-716 of inline_entity_form.module) :
I guess one of the maintainers should look at the consequences of doing this. But it fixes the problem although it could have other repercussions I'm not aware of.
Comment #4
minorwm commentedSame problem here as well. leanderl solution seemed to work for me though.
Comment #5
eme commentedYes indeed, it works very well. It was saving the order only when triggering any AJAX action again, but with this little hack, that's perfect.
Thx !
Comment #6
bojanz commentedFixed in #1489436: Clicking the main save button should save all inline entity forms.
Thanks, guys.