nova-simple-repeatable icon indicating copy to clipboard operation
nova-simple-repeatable copied to clipboard

[2.2.0] Deleting a row leaves rows with a different row index than what is being submitted

Open dmason30 opened this issue 2 years ago • 4 comments

SimpleRepeatable::make('Charges', 'charges',[
  Currency::make('Limit', 'limit')->rules(['required', 'integer', 'min:1', 'distinct'])->step(1),
  Currency::make('Charge', 'charge')->rules(['nullable', 'numeric']),
]),

Steps:

  1. With the above field on a form add 3 rows you will end up with inputs with correct indexes 0,1,2
  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. image
{
    "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."
        ]
    }
}
  1. Delete the first row

  2. Submit the form again with empty fields, only the first row shows The charges.1.limit field is required image

{
    "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.

dmason30 avatar Jul 31 '23 13:07 dmason30

Thank you for report. This will be fixed in the next release.

marttinnotta avatar Sep 20 '23 08:09 marttinnotta

Released in 2.2.1. Good luck!

Tarpsvo avatar Sep 20 '23 08:09 Tarpsvo

@marttinnotta @Tarpsvo Could you reopen this, since the fix was reverted?

dmason30 avatar Oct 20 '23 10:10 dmason30

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.

marttinnotta avatar Oct 20 '23 11:10 marttinnotta