@error directive is not displaying errors in laravel view

前端 未结 2 1247
时光说笑
时光说笑 2021-01-27 05:33

I\'m working on custom Laravel login implementation. I have returned the error from controller as follows:

$credentials = $request->only(\'email\', \'password         


        
相关标签:
2条回答
  • 2021-01-27 06:21

    Please try it again:

    $credentials = $request->only('email', 'password');
    if (Auth::attempt($credentials)) {
      // Authentication passed...
      return redirect()->intended('surveys');
    }else {
      return redirect()->back()->withErrors(['email' => 'The Message']);
    }
    
    0 讨论(0)
  • 2021-01-27 06:27

    Try this :

    <div class="col-md-6">
         <input id="email" type="email" class="form-control @if($errors->has('email'))  is-invalid @endif " name="email" value="{{ old('email') }}" required autocomplete="email" autofocus>
      @if($errors->has('email'))
          <div class="error"></div>
          <span class="invalid-feedback" role="alert">
               <strong>{{ $errors->first('email') }}</strong>
           </span>
      @endif
    </div>
    
    0 讨论(0)
提交回复
热议问题