[2.2.0] Deleting a row leaves rows with a different row index than what is being submitted
dmason30 opened this issue · 4 comments
dmason30 commented
SimpleRepeatable::make('Charges', 'charges',[
Currency::make('Limit', 'limit')->rules(['required', 'integer', 'min:1', 'distinct'])->step(1),
Currency::make('Charge', 'charge')->rules(['nullable', 'numeric']),
]),
Steps:
- With the above field on a form add 3 rows you will end up with inputs with correct indexes 0,1,2
- Submit the form with empty fields and you will get
The charges.x.limit field is required
on all 3 rows. This is expected.
{
"message": "The charges.0.limit field is required. (and 2 more errors)",
"errors": {
"charges.0.limit": [
"The charges.0.limit field is required."
],
"charges.1.limit": [
"The charges.1.limit field is required."
],
"charges.2.limit": [
"The charges.2.limit field is required."
]
}
}
-
Delete the first row
-
Submit the form again with empty fields, only the first row shows
The charges.1.limit field is required
{
"message": "The charges.0.limit field is required. (and 1 more error)",
"errors": {
"charges.0.limit": [
"The charges.0.limit field is required."
],
"charges.1.limit": [
"The charges.1.limit field is required."
]
}
}
This is because the two rows have indexes 1
and 2
but the data being submitted for validation has indexes 0
and 1
.
marttinnotta commented
Thank you for report. This will be fixed in the next release.
Tarpsvo commented
Released in 2.2.1. Good luck!
dmason30 commented
@marttinnotta @Tarpsvo Could you reopen this, since the fix was reverted?
marttinnotta commented
Thank you for the report!
We had some issues with the update that would send data in FormData format and this was also reverted thanks to that. Will look into it.