From 0a955c043af9acf92aa5d9aa5d2f48f4e40f3195 Mon Sep 17 00:00:00 2001 From: Adam Holmes Date: Thu, 19 Dec 2024 10:44:46 +0000 Subject: [PATCH] Fix issue with cloning form fields always cloning the last item rather than the one that was clicked --- src/Concerns/Schemata.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Concerns/Schemata.php b/src/Concerns/Schemata.php index e38a76f9..8158c7a8 100644 --- a/src/Concerns/Schemata.php +++ b/src/Concerns/Schemata.php @@ -368,9 +368,9 @@ public static function getSectionsSchema(): array ->cloneable() ->minItems(1) - ->cloneAction(fn (Action $action) => $action->action(function (Component $component) { + ->cloneAction(fn(Action $action) => $action->action(function (Component $component, $arguments) { $items = $component->getState(); - $originalItem = end($items); + $originalItem = $items[$arguments['item']]; $clonedItem = array_merge($originalItem, [ 'name' => $originalItem['name'] . ' new', 'options' => [