Skip to content

Fix grouped errors not rendering on the update operation - #6083

Merged
tabacitu merged 1 commit into
Laravel-Backpack:mainfrom
tabacitu:fix-grouped-errors-on-update
Sep 17, 2026
Merged

tabacitu merged 1 commit into
Laravel-Backpack:mainfrom
tabacitu:fix-grouped-errors-on-update

Conversation

@tabacitu

Copy link
Copy Markdown
Member

Problem

Since #5911 (fix for #5908) the hidden _form_id input and crud::inc.grouped_errors both fall back to $id on the update operation:

<input type="hidden" name="_form_id" value="{{ $formId ?? $id ?? 'crudForm' }}">
$submittedFormId = old('_form_id') ?? 'crudForm';   // "220" (string, from the request)
$currentFormId = $formId ?? $id ?? 'crudForm';      // 220 (int, the entry key)
@if (!$submittedFormId || $submittedFormId === $currentFormId)

old('_form_id') is always a string, while $id on the update operation is the entry key (an integer for most models), so the strict comparison fails and the grouped error alert never renders on edit forms. Inline errors still work because the JS compares two strings.

This is easy to miss for simple fields because the inline message under the field is enough, but for repeatable fields (where form_content.blade.php deliberately does not append inline messages inside a repeatable-group) the user gets red inputs and no message at all.

Reproduce

On any CRUD with a required field and groupedErrors enabled (the default), open the update form, empty the field and save. On create the red alert with the messages shows at the top; on update it does not.

Fix

Compare both ids as strings.

Tested on backpack/crud 7.0.42 and verified the same code is on main.

🤖 Generated with Claude Code

Since Laravel-Backpack#5911 the hidden _form_id input and the grouped_errors partial both
fall back to $id on the update operation. old('_form_id') is always a
string, while $id is the entry key (an integer for most models), so the
strict comparison in grouped_errors.blade.php fails and the grouped error
alert never renders on edit forms. Compare both values as strings.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
@tabacitu tabacitu added the Minor Bug A bug that happens only in a very niche or specific use case. label Sep 17, 2026
@tabacitu
tabacitu merged commit 9738cfb into Laravel-Backpack:main Sep 17, 2026
8 of 9 checks passed
@tabacitu
tabacitu deleted the fix-grouped-errors-on-update branch September 17, 2026 07:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Minor Bug A bug that happens only in a very niche or specific use case.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants