Skip to content
Snippets Groups Projects
Commit 2a409b43 authored by Lowfidelity Dev Team's avatar Lowfidelity Dev Team Committed by Andrii Podanenko
Browse files

Issue #3061620 by paper boy, mrinalini9: D8: Multiple forms submit/cancel closes all child forms

parent 40c8afef
No related branches found
No related tags found
No related merge requests found
......@@ -1206,8 +1206,21 @@ class InlineEntityFormComplex extends InlineEntityFormBase implements ContainerF
* The form state of the parent form.
*/
public static function closeChildForms(array $form, FormStateInterface &$form_state) {
$element = inline_entity_form_get_element($form, $form_state);
inline_entity_form_close_all_forms($element, $form_state);
// Get the button triggering this action.
$triggering_element = $form_state->getTriggeringElement();
// Slice off 'ief_edit_cancel' and 'actions' keys from it's array parents to
// get to the inline_entity_form.
$array_parents = array_slice($triggering_element['#array_parents'], 0, -2);
// Get the parent IEF form element of the triggering button.
$element = NestedArray::getValue($form, $array_parents);
// Find and close all nested IEF forms of the triggering element.
foreach (Element::children($element) as $key) {
$iefId = NestedArray::getValue($element[$key], ['widget', '#ief_id']);
if (!empty($iefId)) {
inline_entity_form_close_all_forms($element[$key], $form_state);
}
}
}
/**
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment