I am trying to make validation error message for registration with Laravel. But a bit confused about at end of the form stage. I already made a request, setup the controller connection and the other stuff. All of it already over. But in registration.blade in which part of in that form I use this: @if ($errors->first('name')){{ text-danger}} @endif
Every label part? or form part!?
This is my form:
<form class="form-horizontal" role="form" method="post" action="{{url('/auth/register')}}">
{{csrf_field()}}
<div class="row">
<div class="col-md-3"></div>
<div class="col-md-6">
<h2>新ユーザ</h2>
<hr>
</div>
</div>
<div class="row">
<div class="col-md-3 field-label-responsive">
<label for="name">名前</label>
</div>
<div class="col-md-6">
<div class="form-group">
<div class="input-group mb-2 mr-sm-2 mb-sm-0">
<div class="input-group-addon" style="width: 2.6rem"><i class="fa fa-user"></i></div>
<input type="text" name="name" class="form-control" id="name"
placeholder="田中 松本" required autofocus>
</div>
</div>
</div>
<div class="col-md-3">
<div class="form-control-feedback">
<span class="text-danger align-middle">
<!-- Put name validation error messages here -->
</span>
</div>
</div>
</div>
<div class="row">
<div class="col-md-3 field-label-responsive">
<label for="email">E-Mail Address</label>
</div>
<div class="col-md-6">
<div class="form-group">
<div class="input-group mb-2 mr-sm-2 mb-sm-0">
<div class="input-group-addon" style="width: 2.6rem"><i class="fa fa-at"></i></div>
<input type="text" name="email" class="form-control" id="email"
placeholder="you@example.com" required autofocus>
</div>
</div>
</div>
<div class="col-md-3">
<div class="form-control-feedback">
<span class="text-danger align-middle">
<!-- Put e-mail validation error messages here -->
</span>
</div>
</div>
</div>
<div class="row">
<div class="col-md-3 field-label-responsive">
<label for="password">Password</label>
</div>
<div class="col-md-6">
<div class="form-group has-danger">
<div class="input-group mb-2 mr-sm-2 mb-sm-0">
<div class="input-group-addon" style="width: 2.6rem"><i class="fa fa-key"></i></div>
<input type="password" name="password" class="form-control" id="password"
placeholder="Password" required>
</div>
</div>
</div>
<div class="col-md-3">
<div class="form-control-feedback">
<span class="text-danger align-middle">
<i class="fa fa-close"> Example Error Message</i>
</span>
</div>
</div>
</div>
<div class="row">
<div class="col-md-3 field-label-responsive">
<label for="password_confirmation">Confirm Password</label>
</div>
<div class="col-md-6">
<div class="form-group">
<div class="input-group mb-2 mr-sm-2 mb-sm-0">
<div class="input-group-addon" style="width: 2.6rem">
<i class="fa fa-repeat"></i>
</div>
<input type="password" name="password_confirmation" class="form-control"
id="password-confirm" placeholder="Password" required>
</div>
</div>
</div>
</div>
<div class="row">
<div class="col-md-3"></div>
<div class="col-md-6">
<button type="submit" class="btn btn-success"><i class="fa fa-user-plus"></i> Register</button>
</div>
</div>
</form>
Uptade
this is how I did(example):
<div class="col-md-3">
<div class="form-control-feedback @if ($errors->first('name')){{'text-danger'}} @endif ">
<span class="text-danger align-middle">
{{$errors->first('')}}
</span>
</div>
</div>
But it's not working.
also this is my requests
public function rules()
{
return [
'name' => 'required|min:3|max:20',
'email' => 'required|email|unique:users,email',
'password' => 'required|min:6|max:20|confirmed',
'password_conformation' => 'required|min:6|max:20'
];
}
controller
public function register(registerRequest $request)
{
return view('auth.register')->withErrors($request);
}