Sorry, i am a beginner for laravel 5, I try to validate register form but it not showing error message. Any idea why errors are not displaying. Please help.
thank you so much.
Here are my code
View
<form role="form" method="post" action="">
<div class="form-group">
<label for="name">Full Name</label>
<input type="text" name="fullname" class="form-control" id="fullname" value="" placeholder="Enter your fullname">
@if ($errors->has('fullname'))
<span class="help-block"></span>
@endif
</div>
<div class="form-group">
<label for="email" class="control-label">Your email address</label>
<input type="text" name="email" class="form-control" id="email" value="" placeholder="Enter your email">
@if ($errors->has('email'))
<span class="help-block"></span>
@endif
</div>
<div class="form-group">
<label for="password" class="control-label">Choose a password</label>
<input type="password" name="password" class="form-control" id="password" placeholder="Enter your password">
@if ($errors->has('password'))
<span class="help-block"></span>
@endif
</div>
<div class="form-group">
<label class="control-label">Confirm Password</label>
<input type="password" class="form-control" name="password_confirmation" placeholder="Re-Enter your password">
@if ($errors->has('password_confirmation'))
<span class="help-block">
<strong></strong>
</span>
@endif
</div>
<input type="hidden" name="activated" value="0">
<input type="hidden" name="_token" value="">
<button type="submit" class="btn btn-warning btn-sm">Submit</button>
<button type="reset" class="btn btn-default btn-sm">Reset</button>
</form>
Controller
public function postRegister(Request $request) {
$this->validate($request, [
'email' => 'required|email|max:255',
'password' =>'required|alphaNum|Between:4,8|Confirmed',
'password_confirmation'=>'required|alphaNum|Between:4,8',
'fullname' => 'required|max:255',
'activated' => 'required',
]);
Admin::create([
'email' => $request->input('email'),
'password' => $request->input('password'),
'fullname' => $request->input('fullname'),
'activated' => $request->input('activated')
]);
return redirect('backoffice/register')->with('info', 'register successfully!');
}
Route
Route::get('backoffice/register', 'AdminAuthController@getRegister');
Route::post('/backoffice/register', 'AdminAuthController@postRegister');
via Chebli Mohamed
Aucun commentaire:
Enregistrer un commentaire