Hi I have a code with custom formrequest request, I want to display custom error message, but the input name format is of the form of array, so how to display that specific error against each of these fields, consider the code below:
blade
@foreach($projects as $project)
<input type="text" name="project[]" value="" required>
{{- piece of code to show error message against this field -}}
@endforeach
request
return [
'project[]' => 'required|max:30'
];
CodePudding user response:
Try this
@if($errors->has('project'))
<em class="invalid-feedback">
{{ $errors->first('project[{{$project->id}}]') }}
</em>
@endif
Assuming $project->id
is present unless you can use other variable.