CRUD icon indicating copy to clipboard operation
CRUD copied to clipboard

[Bug] `repeatable` subfield error messages are a bit odd

Open tabacitu opened this issue 3 years ago • 4 comments

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

Screenshot 2022-01-18 at 11 28 48

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

tabacitu avatar Jan 18 '22 09:01 tabacitu

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 ?

niladam avatar Mar 21 '22 09:03 niladam

I think Pedro had a PR/idea that was also fixing this - @pxpm can you please update us on that?

tabacitu avatar Mar 21 '22 10:03 tabacitu

@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

pxpm avatar Mar 21 '22 15:03 pxpm

@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!:)

niladam avatar Mar 22 '22 09:03 niladam

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

pxpm avatar Aug 30 '22 09:08 pxpm