laravel-admin icon indicating copy to clipboard operation
laravel-admin copied to clipboard

HasMany field new_{index} key in js resets to zero after validation fails

Open alexoleynik0 opened this issue 9 months ago • 0 comments

  • Laravel Version: 9.50.2
  • PHP Version: 8.0.2
  • Laravel-admin: 1.8.19

Description:

When using HasMany field and validation fails somewhere in the Form, it resets new items index to zero always, so if you try to add new Item on the second attempt, you will have to HasMany items with key new_1, which will override one another without any warnings.

Steps To Reproduce:

  • Create form with HasMany field.
  • Make some fields of the main Instance required and not fill them. Add one Item to HasMany field, fill its inputs.
  • Submit the From. See errors.
  • Add another Item to HasMany field. Submit the form again (so that error happens or not).
  • See that you now have only one Item in your HasMany field list (the last one of two).

And all this even assuming you have followed the instruction described in this issue, regarding wrong key mapping in the HasMany field after validation fails. Without it you will see your HasMany Items disappearing on every form submit.

alexoleynik0 avatar Sep 14 '23 14:09 alexoleynik0