From 9427def402c055f4ba50db2cc1b9d52f2961fc7d Mon Sep 17 00:00:00 2001 From: Grevil Date: Tue, 19 Aug 2025 15:17:06 +0200 Subject: [PATCH 1/9] First push --- .../FieldWidget/InlineEntityFormSimple.php | 63 +++++++++++++++---- 1 file changed, 52 insertions(+), 11 deletions(-) diff --git a/src/Plugin/Field/FieldWidget/InlineEntityFormSimple.php b/src/Plugin/Field/FieldWidget/InlineEntityFormSimple.php index 42fa2f5..e23e834 100644 --- a/src/Plugin/Field/FieldWidget/InlineEntityFormSimple.php +++ b/src/Plugin/Field/FieldWidget/InlineEntityFormSimple.php @@ -92,17 +92,32 @@ class InlineEntityFormSimple extends InlineEntityFormBase { // If we're using unlimited cardinality we don't display one empty item. // Form validation will kick in if left empty which essentially means // people won't be able to submit without creating another entity. - if (!$form_state->isSubmitted() && $element['#cardinality'] == FieldStorageDefinitionInterface::CARDINALITY_UNLIMITED && $element['#max_delta'] > 0) { - $max = $element['#max_delta']; - unset($element[$max]); - $element['#max_delta'] = $max - 1; - $items->removeItem($max); - // Decrement the items count. - $field_name = $element['#field_name']; - $parents = $element[0]['#field_parents']; - $field_state = static::getWidgetState($parents, $field_name, $form_state); - $field_state['items_count']--; - static::setWidgetState($parents, $field_name, $form_state, $field_state); + $deleteTriggered = isset($form_state->getTriggeringElement()['#submit'][0]) && in_array('deleteSubmit', $form_state->getTriggeringElement()['#submit'][0]); + if ((!$form_state->isSubmitted() || $deleteTriggered) && $element['#cardinality'] == FieldStorageDefinitionInterface::CARDINALITY_UNLIMITED) { + // @todo Add setting to check: + if ($element['#max_delta'] > 0) { + $max = $element['#max_delta']; + unset($element[$max]); + $element['#max_delta'] = $max - 1; + $items->removeItem($max); + // Decrement the items count. + $field_name = $element['#field_name']; + $parents = $element[0]['#field_parents']; + $field_state = static::getWidgetState($parents, $field_name, $form_state); + $field_state['items_count']--; + static::setWidgetState($parents, $field_name, $form_state, $field_state); + } + else { + // If there are not items, do not show the empty item: + $max = $element['#max_delta']; + unset($element[$max]); + $items->removeItem($max); + // Also adjust the add_more label: + if (isset($element['add_more'])) { + $element['add_more']['#value'] = $this->t('Add item'); + } + } + } // Remove add options if the user cannot add new entities. @@ -122,6 +137,32 @@ class InlineEntityFormSimple extends InlineEntityFormBase { return $element; } + /** + * {@inheritdoc} + */ + public static function addMoreSubmit(array $form, FormStateInterface $form_state) { + $button = $form_state->getTriggeringElement(); + + // Go one level up in the form, to the widgets container. + $element = NestedArray::getValue($form, array_slice($button['#array_parents'], 0, -1)); + $field_name = $element['#field_name']; + $parents = $element['#field_parents']; + + $field_state = static::getWidgetState($parents, $field_name, $form_state); + $elementChildren = Element::children($element); + // The "add_more" button can also be part of the children. If that is the + // case, increase the allowed children count by one: + $allowedChildrenCount = in_array('add_more', $elementChildren) ? 1 : 0; + // Only increse the items count, if any item exists, otherwise we simply + // create the 0th item: + if (count($elementChildren) > $allowedChildrenCount) { + $field_state['items_count']++; + } + static::setWidgetState($parents, $field_name, $form_state, $field_state); + + $form_state->setRebuild(); + } + /** * {@inheritdoc} */ -- GitLab From 8ec9fc096ed5961b57605ea8bb25cde8250469a2 Mon Sep 17 00:00:00 2001 From: Grevil Date: Tue, 19 Aug 2025 16:24:34 +0200 Subject: [PATCH 2/9] Further changes --- .../FieldWidget/InlineEntityFormSimple.php | 63 ++++++++++++++++++- 1 file changed, 60 insertions(+), 3 deletions(-) diff --git a/src/Plugin/Field/FieldWidget/InlineEntityFormSimple.php b/src/Plugin/Field/FieldWidget/InlineEntityFormSimple.php index e23e834..ccd84c3 100644 --- a/src/Plugin/Field/FieldWidget/InlineEntityFormSimple.php +++ b/src/Plugin/Field/FieldWidget/InlineEntityFormSimple.php @@ -27,6 +27,49 @@ use Drupal\rat\v1\RenderArray; */ class InlineEntityFormSimple extends InlineEntityFormBase { + /** + * {@inheritdoc} + */ + public static function defaultSettings() { + $settings = parent::defaultSettings(); + $settings += [ + 'do_not_show_initial_empty_item' => FALSE, + ]; + + return $settings; + } + + /** + * {@inheritdoc} + */ + public function settingsForm(array $form, FormStateInterface $form_state) { + $element = parent::settingsForm($form, $form_state); + $element['do_not_show_initial_empty_item'] = [ + '#type' => 'checkbox', + '#title' => $this->t('Do not show empty items'), + '#description' => $this->t('This option makes it so there is no initial inline form open for the user. He has to click the add button to create the initial one.'), + '#default_value' => $this->getSetting('do_not_show_initial_empty_item'), + ]; + + return $element; + } + + /** + * {@inheritdoc} + */ + public function settingsSummary() { + $summary = parent::settingsSummary(); + + if ($this->getSetting('do_not_show_initial_empty_item')) { + $summary[] = $this->t('Do not show initial empty item.'); + } + else { + $summary[] = $this->t('Show initial empty item.'); + } + + return $summary; + } + /** * {@inheritdoc} */ @@ -92,9 +135,14 @@ class InlineEntityFormSimple extends InlineEntityFormBase { // If we're using unlimited cardinality we don't display one empty item. // Form validation will kick in if left empty which essentially means // people won't be able to submit without creating another entity. + // @todo The $deleteTriggered is needed, so if we have one empty inline + // entity form, we can remove it. + // The problem is that core has no difference between no items and one empty + // item. Meaning, if we add two inline entity forms and delete one, both get + // deleted, because for some reason in this case "$element['#max_delta']" is + // 0: $deleteTriggered = isset($form_state->getTriggeringElement()['#submit'][0]) && in_array('deleteSubmit', $form_state->getTriggeringElement()['#submit'][0]); if ((!$form_state->isSubmitted() || $deleteTriggered) && $element['#cardinality'] == FieldStorageDefinitionInterface::CARDINALITY_UNLIMITED) { - // @todo Add setting to check: if ($element['#max_delta'] > 0) { $max = $element['#max_delta']; unset($element[$max]); @@ -107,7 +155,8 @@ class InlineEntityFormSimple extends InlineEntityFormBase { $field_state['items_count']--; static::setWidgetState($parents, $field_name, $form_state, $field_state); } - else { + elseif ($this->getSetting('do_not_show_initial_empty_item')) { + $form_state->getValues(); // If there are not items, do not show the empty item: $max = $element['#max_delta']; unset($element[$max]); @@ -133,6 +182,14 @@ class InlineEntityFormSimple extends InlineEntityFormBase { } } } + if ($this->getSetting('do_not_show_initial_empty_item')) { + if (isset($element['add_more']['#submit'])) { + $index = array_search([static::class, 'addMoreSubmit'], $element['add_more']['#submit']); + if ($index !== NULL) { + $element['add_more']['#submit'][$index] = [static::class, 'addMoreSubmitOverride']; + } + } + } return $element; } @@ -140,7 +197,7 @@ class InlineEntityFormSimple extends InlineEntityFormBase { /** * {@inheritdoc} */ - public static function addMoreSubmit(array $form, FormStateInterface $form_state) { + public static function addMoreSubmitOverride(array $form, FormStateInterface $form_state) { $button = $form_state->getTriggeringElement(); // Go one level up in the form, to the widgets container. -- GitLab From 48b19f1c27dafdcbc130fde15193308249297930 Mon Sep 17 00:00:00 2001 From: Grevil Date: Wed, 20 Aug 2025 10:56:03 +0200 Subject: [PATCH 3/9] Fix accidental removal of filled inline entities --- .../FieldWidget/InlineEntityFormSimple.php | 86 +++++++++++++------ 1 file changed, 59 insertions(+), 27 deletions(-) diff --git a/src/Plugin/Field/FieldWidget/InlineEntityFormSimple.php b/src/Plugin/Field/FieldWidget/InlineEntityFormSimple.php index ccd84c3..a0d390b 100644 --- a/src/Plugin/Field/FieldWidget/InlineEntityFormSimple.php +++ b/src/Plugin/Field/FieldWidget/InlineEntityFormSimple.php @@ -135,38 +135,40 @@ class InlineEntityFormSimple extends InlineEntityFormBase { // If we're using unlimited cardinality we don't display one empty item. // Form validation will kick in if left empty which essentially means // people won't be able to submit without creating another entity. - // @todo The $deleteTriggered is needed, so if we have one empty inline - // entity form, we can remove it. - // The problem is that core has no difference between no items and one empty - // item. Meaning, if we add two inline entity forms and delete one, both get - // deleted, because for some reason in this case "$element['#max_delta']" is - // 0: + + // This whole deleteTriggered logic is only needed, because "deleteSubmit" + // is properly deleteing the item, but parent::formMultipleElements creates + // a new one by default: $deleteTriggered = isset($form_state->getTriggeringElement()['#submit'][0]) && in_array('deleteSubmit', $form_state->getTriggeringElement()['#submit'][0]); if ((!$form_state->isSubmitted() || $deleteTriggered) && $element['#cardinality'] == FieldStorageDefinitionInterface::CARDINALITY_UNLIMITED) { - if ($element['#max_delta'] > 0) { - $max = $element['#max_delta']; - unset($element[$max]); - $element['#max_delta'] = $max - 1; - $items->removeItem($max); - // Decrement the items count. - $field_name = $element['#field_name']; - $parents = $element[0]['#field_parents']; - $field_state = static::getWidgetState($parents, $field_name, $form_state); - $field_state['items_count']--; - static::setWidgetState($parents, $field_name, $form_state, $field_state); - } - elseif ($this->getSetting('do_not_show_initial_empty_item')) { - $form_state->getValues(); - // If there are not items, do not show the empty item: - $max = $element['#max_delta']; + // Get the user input values on the field: + $fieldInput = $form_state->getUserInput()[$element['#field_name']] ?? []; + $userInputValues = $this->getUserInputValuesRecursively($fieldInput); + // Get the pre-existing values of the field: + $max = $element['#max_delta']; + $itemValues = $items->getValue()[$max]; + // Check that the element we want to unset is really empty: + if ((empty($itemValues) && empty($userInputValues)) || !$form_state->isSubmitted()) { unset($element[$max]); - $items->removeItem($max); - // Also adjust the add_more label: - if (isset($element['add_more'])) { - $element['add_more']['#value'] = $this->t('Add item'); + if ($element['#max_delta'] > 0) { + $element['#max_delta'] = $max - 1; + $items->removeItem($max); + // Decrement the items count. + $field_name = $element['#field_name']; + $parents = $element[0]['#field_parents']; + $field_state = static::getWidgetState($parents, $field_name, $form_state); + $field_state['items_count']--; + static::setWidgetState($parents, $field_name, $form_state, $field_state); + } + elseif ($this->getSetting('do_not_show_initial_empty_item')) { + // If there are no items, do not show the empty item: + $items->removeItem($max); + // Also adjust the add_more label: + if (isset($element['add_more'])) { + $element['add_more']['#value'] = $this->t('Add item'); + } } } - } // Remove add options if the user cannot add new entities. @@ -194,6 +196,36 @@ class InlineEntityFormSimple extends InlineEntityFormBase { return $element; } + /** + * Recursively extracts user input values from a nested array structure. + * + * This method traverses through a multi-dimensional array to collect user + * input values. + * + * @param array $array + * The array to process recursively for user input values. + * + * @return array + * The user input values. + */ + protected function getUserInputValuesRecursively(array $array) { + $values = []; + + foreach ($array as $key => $value) { + if (is_array($value)) { + // Recursively filter nested arrays and merge results. + $nestedValues = $this->getUserInputValuesRecursively($value); + $values = array_merge($values, $nestedValues); + } + elseif ($key === 'value' && is_string($value) && trim($value) !== '') { + // Add non-empty 'value' entries to the flat array. + $values[] = $value; + } + } + + return $values; + } + /** * {@inheritdoc} */ -- GitLab From 69dbf08603531e40acdf69d343209baee6b0687e Mon Sep 17 00:00:00 2001 From: Grevil Date: Wed, 20 Aug 2025 11:17:03 +0200 Subject: [PATCH 4/9] Clean up code --- .../FieldWidget/InlineEntityFormSimple.php | 69 +++++++++++-------- 1 file changed, 42 insertions(+), 27 deletions(-) diff --git a/src/Plugin/Field/FieldWidget/InlineEntityFormSimple.php b/src/Plugin/Field/FieldWidget/InlineEntityFormSimple.php index a0d390b..46d0a6b 100644 --- a/src/Plugin/Field/FieldWidget/InlineEntityFormSimple.php +++ b/src/Plugin/Field/FieldWidget/InlineEntityFormSimple.php @@ -135,39 +135,20 @@ class InlineEntityFormSimple extends InlineEntityFormBase { // If we're using unlimited cardinality we don't display one empty item. // Form validation will kick in if left empty which essentially means // people won't be able to submit without creating another entity. - // This whole deleteTriggered logic is only needed, because "deleteSubmit" // is properly deleteing the item, but parent::formMultipleElements creates // a new one by default: - $deleteTriggered = isset($form_state->getTriggeringElement()['#submit'][0]) && in_array('deleteSubmit', $form_state->getTriggeringElement()['#submit'][0]); - if ((!$form_state->isSubmitted() || $deleteTriggered) && $element['#cardinality'] == FieldStorageDefinitionInterface::CARDINALITY_UNLIMITED) { - // Get the user input values on the field: + $deleteTriggered = $this->isDeleteTriggered($form_state); + $isUnlimitedCardinality = $element['#cardinality'] == FieldStorageDefinitionInterface::CARDINALITY_UNLIMITED; + + if ((!$form_state->isSubmitted() || $deleteTriggered) && $isUnlimitedCardinality) { $fieldInput = $form_state->getUserInput()[$element['#field_name']] ?? []; $userInputValues = $this->getUserInputValuesRecursively($fieldInput); - // Get the pre-existing values of the field: $max = $element['#max_delta']; - $itemValues = $items->getValue()[$max]; - // Check that the element we want to unset is really empty: - if ((empty($itemValues) && empty($userInputValues)) || !$form_state->isSubmitted()) { - unset($element[$max]); - if ($element['#max_delta'] > 0) { - $element['#max_delta'] = $max - 1; - $items->removeItem($max); - // Decrement the items count. - $field_name = $element['#field_name']; - $parents = $element[0]['#field_parents']; - $field_state = static::getWidgetState($parents, $field_name, $form_state); - $field_state['items_count']--; - static::setWidgetState($parents, $field_name, $form_state, $field_state); - } - elseif ($this->getSetting('do_not_show_initial_empty_item')) { - // If there are no items, do not show the empty item: - $items->removeItem($max); - // Also adjust the add_more label: - if (isset($element['add_more'])) { - $element['add_more']['#value'] = $this->t('Add item'); - } - } + $itemValues = $items->getValue()[$max] ?? []; + + if (empty($itemValues) && empty($userInputValues) || !$form_state->isSubmitted()) { + $this->removeEmptyItem($element, $items, $max, $form_state); } } @@ -196,6 +177,40 @@ class InlineEntityFormSimple extends InlineEntityFormBase { return $element; } + /** + * Checks if a delete action was triggered. + */ + protected function isDeleteTriggered(FormStateInterface $form_state): bool { + $triggering_element = $form_state->getTriggeringElement(); + return isset($triggering_element['#submit'][0]) && + in_array('deleteSubmit', $triggering_element['#submit'][0]); + } + + /** + * Removes an empty item from the form element and items list. + */ + protected function removeEmptyItem(array &$element, FieldItemListInterface $items, int $max, FormStateInterface $form_state): void { + unset($element[$max]); + + if ($element['#max_delta'] > 0) { + $element['#max_delta'] = $max - 1; + $items->removeItem($max); + + $field_name = $element['#field_name']; + $parents = $element[0]['#field_parents']; + $field_state = static::getWidgetState($parents, $field_name, $form_state); + $field_state['items_count']--; + static::setWidgetState($parents, $field_name, $form_state, $field_state); + } + elseif ($this->getSetting('do_not_show_initial_empty_item')) { + $items->removeItem($max); + + if (isset($element['add_more'])) { + $element['add_more']['#value'] = $this->t('Add item'); + } + } + } + /** * Recursively extracts user input values from a nested array structure. * -- GitLab From 03745124d24331d8b96777917725bae3e6158a79 Mon Sep 17 00:00:00 2001 From: Grevil Date: Wed, 20 Aug 2025 11:44:08 +0200 Subject: [PATCH 5/9] Remove item validation --- src/Plugin/Field/FieldWidget/InlineEntityFormSimple.php | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/src/Plugin/Field/FieldWidget/InlineEntityFormSimple.php b/src/Plugin/Field/FieldWidget/InlineEntityFormSimple.php index 46d0a6b..292f749 100644 --- a/src/Plugin/Field/FieldWidget/InlineEntityFormSimple.php +++ b/src/Plugin/Field/FieldWidget/InlineEntityFormSimple.php @@ -144,11 +144,9 @@ class InlineEntityFormSimple extends InlineEntityFormBase { if ((!$form_state->isSubmitted() || $deleteTriggered) && $isUnlimitedCardinality) { $fieldInput = $form_state->getUserInput()[$element['#field_name']] ?? []; $userInputValues = $this->getUserInputValuesRecursively($fieldInput); - $max = $element['#max_delta']; - $itemValues = $items->getValue()[$max] ?? []; - if (empty($itemValues) && empty($userInputValues) || !$form_state->isSubmitted()) { - $this->removeEmptyItem($element, $items, $max, $form_state); + if (empty($userInputValues) || !$form_state->isSubmitted()) { + $this->removeEmptyItem($element, $items, $form_state); } } @@ -189,7 +187,8 @@ class InlineEntityFormSimple extends InlineEntityFormBase { /** * Removes an empty item from the form element and items list. */ - protected function removeEmptyItem(array &$element, FieldItemListInterface $items, int $max, FormStateInterface $form_state): void { + protected function removeEmptyItem(array &$element, FieldItemListInterface $items, FormStateInterface $form_state): void { + $max = $element['#max_delta']; unset($element[$max]); if ($element['#max_delta'] > 0) { -- GitLab From 752a0c340fddb2598837b13284ff5c705bd8a590 Mon Sep 17 00:00:00 2001 From: Grevil Date: Wed, 20 Aug 2025 11:52:06 +0200 Subject: [PATCH 6/9] Improve performance --- src/Plugin/Field/FieldWidget/InlineEntityFormSimple.php | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/src/Plugin/Field/FieldWidget/InlineEntityFormSimple.php b/src/Plugin/Field/FieldWidget/InlineEntityFormSimple.php index 292f749..34c9c22 100644 --- a/src/Plugin/Field/FieldWidget/InlineEntityFormSimple.php +++ b/src/Plugin/Field/FieldWidget/InlineEntityFormSimple.php @@ -142,10 +142,9 @@ class InlineEntityFormSimple extends InlineEntityFormBase { $isUnlimitedCardinality = $element['#cardinality'] == FieldStorageDefinitionInterface::CARDINALITY_UNLIMITED; if ((!$form_state->isSubmitted() || $deleteTriggered) && $isUnlimitedCardinality) { - $fieldInput = $form_state->getUserInput()[$element['#field_name']] ?? []; - $userInputValues = $this->getUserInputValuesRecursively($fieldInput); - - if (empty($userInputValues) || !$form_state->isSubmitted()) { + $max = $element['#max_delta']; + $fieldInput = $form_state->getUserInput()[$element['#field_name']][$max] ?? []; + if (!$form_state->isSubmitted() || empty($this->getUserInputValuesRecursively($fieldInput))) { $this->removeEmptyItem($element, $items, $form_state); } } -- GitLab From 56c1f1477aabf1b47597a0d722b9b91f3477c170 Mon Sep 17 00:00:00 2001 From: Grevil Date: Thu, 21 Aug 2025 09:23:23 +0200 Subject: [PATCH 7/9] Reintroduce items check and add schema --- config/schema/inline_entity_form.schema.yml | 3 +++ src/Plugin/Field/FieldWidget/InlineEntityFormSimple.php | 3 ++- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/config/schema/inline_entity_form.schema.yml b/config/schema/inline_entity_form.schema.yml index 2d7a8f2..377b554 100644 --- a/config/schema/inline_entity_form.schema.yml +++ b/config/schema/inline_entity_form.schema.yml @@ -37,6 +37,9 @@ field.widget.settings.inline_entity_form_simple: removed_reference: type: string label: "Keep or delete unreferenced items" + do_not_show_initial_empty_item: + type: boolean + label: "Do not show initial empty item" field.widget.settings.inline_entity_form_complex: type: mapping diff --git a/src/Plugin/Field/FieldWidget/InlineEntityFormSimple.php b/src/Plugin/Field/FieldWidget/InlineEntityFormSimple.php index 34c9c22..79a7e96 100644 --- a/src/Plugin/Field/FieldWidget/InlineEntityFormSimple.php +++ b/src/Plugin/Field/FieldWidget/InlineEntityFormSimple.php @@ -144,7 +144,8 @@ class InlineEntityFormSimple extends InlineEntityFormBase { if ((!$form_state->isSubmitted() || $deleteTriggered) && $isUnlimitedCardinality) { $max = $element['#max_delta']; $fieldInput = $form_state->getUserInput()[$element['#field_name']][$max] ?? []; - if (!$form_state->isSubmitted() || empty($this->getUserInputValuesRecursively($fieldInput))) { + $itemValues = $items->getValue()[$max] ?? []; + if (!$form_state->isSubmitted() || empty($itemValues) && empty($this->getUserInputValuesRecursively($fieldInput))) { $this->removeEmptyItem($element, $items, $form_state); } } -- GitLab From 928079d0fe4d7ac03780c0dff43d89f1461bd1d3 Mon Sep 17 00:00:00 2001 From: Grevil Date: Thu, 21 Aug 2025 10:15:35 +0200 Subject: [PATCH 8/9] Add further fieldValueKeys --- src/Plugin/Field/FieldWidget/InlineEntityFormSimple.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/Plugin/Field/FieldWidget/InlineEntityFormSimple.php b/src/Plugin/Field/FieldWidget/InlineEntityFormSimple.php index 79a7e96..1379386 100644 --- a/src/Plugin/Field/FieldWidget/InlineEntityFormSimple.php +++ b/src/Plugin/Field/FieldWidget/InlineEntityFormSimple.php @@ -223,6 +223,7 @@ class InlineEntityFormSimple extends InlineEntityFormBase { * The user input values. */ protected function getUserInputValuesRecursively(array $array) { + $fieldValueKeys = ['value', 'target_id', 'number']; $values = []; foreach ($array as $key => $value) { @@ -231,7 +232,7 @@ class InlineEntityFormSimple extends InlineEntityFormBase { $nestedValues = $this->getUserInputValuesRecursively($value); $values = array_merge($values, $nestedValues); } - elseif ($key === 'value' && is_string($value) && trim($value) !== '') { + elseif (in_array($key, $fieldValueKeys) && is_string($value) && trim($value) !== '') { // Add non-empty 'value' entries to the flat array. $values[] = $value; } -- GitLab From 03cb82191bf2d87146763de47d5f325e4f19e5f5 Mon Sep 17 00:00:00 2001 From: Claudiu Cristea <7931-claudiucristea@users.noreply.drupalcode.org> Date: Fri, 5 Dec 2025 12:41:58 +0000 Subject: [PATCH 9/9] Additional check --- src/Plugin/Field/FieldWidget/InlineEntityFormSimple.php | 1 + 1 file changed, 1 insertion(+) diff --git a/src/Plugin/Field/FieldWidget/InlineEntityFormSimple.php b/src/Plugin/Field/FieldWidget/InlineEntityFormSimple.php index 1379386..edcd142 100644 --- a/src/Plugin/Field/FieldWidget/InlineEntityFormSimple.php +++ b/src/Plugin/Field/FieldWidget/InlineEntityFormSimple.php @@ -181,6 +181,7 @@ class InlineEntityFormSimple extends InlineEntityFormBase { protected function isDeleteTriggered(FormStateInterface $form_state): bool { $triggering_element = $form_state->getTriggeringElement(); return isset($triggering_element['#submit'][0]) && + is_array($triggering_element['#submit'][0]) && in_array('deleteSubmit', $triggering_element['#submit'][0]); } -- GitLab