Description
Bug description
When creating a Grid field with any field as its "child" that has validation rules, the errors corresponding to said rules are set on the item index and not the item itself. Meaning that when I have 3 grid items and I get an validation error on item 2 (thus item 1 and 3 being valid), when I then remove item 2 the validation error doesn't go away but instead item 3 is now in the position of where item 2 was and now the validation error appears on item 3.
How to reproduce
Create a simple grid field with a field having a validation rule as its "child". YAML example:
handle: grid_field
field:
min_rows: 1
type: grid
display: 'Grid Field'
localizable: false
fields:
-
handle: text
field:
type: text
display: Text
localizable: false
validate:
- required
Use it in an entry with some empty rows, try to save, see the validation errors and try to remove those rows with validation errors.
A screencap to hopefully provide more clarity:
Screen.Recording.2024-08-27.at.09.59.00.mov
Logs
No response
Environment
Environment
Application Name: Statamic
Laravel Version: 11.10.0
PHP Version: 8.2.22
Composer Version: 2.7.7
Environment: local
Debug Mode: ENABLED
URL: <project>-statamic.test
Maintenance Mode: OFF
Cache
Config: NOT CACHED
Events: NOT CACHED
Routes: NOT CACHED
Views: CACHED
Drivers
Broadcasting: null
Cache: statamic
Database: mysql
Logs: stack / single
Mail: smtp
Queue: sync
Session: file
Statamic
Addons: 3
Sites: 38 (Default, NL, EN, and 35 more)
Stache Watcher: Disabled
Static Caching: Disabled
Version: 5.21.0 PRO
Statamic Addons
aerni/advanced-seo: 2.5.3
rias/statamic-redirect: 3.7.1
Installation
Fresh statamic/statamic site via CLI
Additional details
No response