Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
dmason30 opened this issue Jul 31, 2023 · 4 comments
Labels
bug Something isn't working

Comments

@dmason30
Copy link

dmason30 commented Jul 31, 2023

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.

@marttinnotta
Copy link
Contributor

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

@Tarpsvo
Copy link
Contributor

Tarpsvo commented Sep 20, 2023

Released in 2.2.1. Good luck!

@dmason30
Copy link
Author

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

@marttinnotta marttinnotta reopened this Oct 20, 2023
@marttinnotta
Copy link
Contributor

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.

@p-jrv p-jrv added the bug Something isn't working label Dec 1, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

4 participants