0

I have array of dropdown with the same name what i'm trying to do is to display the actual name of the field when the error is displayed but now it is displaying like

attributes.Size Attributes Fields are required

where size is the title that i'm passing dynamically

but i want actual name which i am passing as a title to an array.

Code:

$validator = Validator::make($request->all(), [
 'attributes.*' => 'required',
 ],[
 'attributes.*.required' => ':attribute Attributes Fields are required.',
 ]);

 {!! Form::select('attributes['.$attr->title.']') !!}
3
  • Very difficult to understand. I would like to suggest a better grammar.
    – manix
    Commented Jan 28, 2020 at 7:52
  • I'm getting validation errors for required array field as index values, but i want actual name. Commented Jan 28, 2020 at 7:55
  • Instead of making a custom validator, you could use a FormRequest and use the message() methods to display a custom message. laravel.com/docs/6.x/validation#form-request-validation
    – LobsterBaz
    Commented Jan 28, 2020 at 8:30

0

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.