This is my code, double form so this is the same input name like eg. email. When i send form with empty email field i have an error how can i display one error to one correct form. Now of course i see this error on each form.
<form action="{{ route('signup') }}" method="post" class="col-md-9" id="webinar-form-{{ $data->id }}">
@csrf
<div class="input-group mb-3">
<input type="text" class="form-control @error('email') is-invalid @enderror" name="email" value="{{ old('email') }}" placeholder="Adres email">
<button type="submit" class="btn btn-primary">Sign Up</button>
</div>
@error('email')
<div class="alert alert-light" role="alert">
<span class="text-danger">{{ $message }}</span>
</div>
@enderror
</form>
<form action="{{ route('signup') }}" method="post" class="col-md-9" id="webinar-form-{{ $data->id }}">
@csrf
<div class="input-group mb-3">
<input type="text" class="form-control @error('email') is-invalid @enderror" name="email" value="{{ old('email') }}" placeholder="Adres email">
<button type="submit" class="btn btn-primary">Sign Up</button>
</div>
@error('email')
<div class="alert alert-light" role="alert">
<span class="text-danger">{{ $message }}</span>
</div>
@enderror
</form>
2
Answers
You need to change the name of your email, probably something like this
Because your input name is same for both form. And you can set the variable in your controller to match the name
You need to use array validation in laravel
Use this code in controller and check it’s working or not.