Skip to content

Commit

Permalink
[4.x] Fix "A field with a handle of X already exists" error when edit…
Browse files Browse the repository at this point in the history
…ing fieldsets (#9718)
  • Loading branch information
duncanmcclean committed Mar 12, 2024
1 parent d08d2cd commit 1ff8052
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion src/Http/Controllers/CP/Fields/FieldsController.php
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ public function update(Request $request)
'handle' => [
function ($attribute, $value, $fail) use ($request) {
$existingFieldWithHandle = collect($request->fields ?? [])
->when($request->id, fn ($collection) => $collection->reject(fn ($field) => $field['_id'] === $request->id))
->when($request->has('id'), fn ($collection) => $collection->reject(fn ($field) => $field['_id'] === $request->id))
->flatMap(function (array $field) {
if ($field['type'] === 'import') {
return Fieldset::find($field['fieldset'])->fields()->all()->map->handle()->toArray();
Expand Down

0 comments on commit 1ff8052

Please sign in to comment.