CRUD
CRUD copied to clipboard
[Bug] `repeatable` subfield error messages are a bit odd
Bug report
What I did
Made a repeatable subfield required (using nested array validation, present in 4.2).
What I expected to happen
Nice error message when "quantity" subfield is missing.
What happened
I wonder if there's anything we can do to
- turn
The items.0.quantity field is required - into
the item quantity field is required for row 0
Or... I don't know... maybe even something better than that. At least a way to tell people "define this in your FormRequest's messages().
What I've already tried to fix it
Nothing. In a rush to ship 4.2.
Is it a bug in the latest version of Backpack?
4.2
Somehow, i'm also affected by this. I'm using a FormRequest for the fields but i seem to not be able to change/define the messages ?
I think Pedro had a PR/idea that was also fixing this - @pxpm can you please update us on that?
@niladam for a field you validate with: 'repeatable.*.field_name'=> 'required' you can put in your messages: repeatable.*.field_name.required => 'this field is required'.
The PR that works on this is: https://github.com/Laravel-Backpack/CRUD/pull/4220/files but is mainly so that you can validate directly on the fields with validationRules => 'required' and it will process it to be usable in a FormRequest. . For a FormRequest validation is standard laravel nested input validation https://laravel.com/docs/9.x/validation#validating-nested-array-input
@niladam for a field you validate with:
'repeatable.*.field_name'=> 'required'you can put in your messages:repeatable.*.field_name.required => 'this field is required'.
Dude, you're so right. I was simply adding the messages without the target (.required) and seeing its not working. I dont know how i missed it. Thank you for the reminder!:)
I think this is done. 👍
I've just tested repeatable messages and everything is displaying correctly.
This was a misunderstanding on how to display repeatable messages.
I am closing this, please re-open if you guys think I am wrong.
Cheers