2016-11-12 18 views
3

1ページに登録とログインの両方を持つページを作成していました。
私のコードは、私がスタイリングのためのブートストラップとW3Schoolsのを使用して、このlaravelの1ページに登録とログインフォーム5.3

<div class="w3-display-container w3-white"> 
    <div style="white-space:nowrap;" class="container"> 
     <h2>Already have an account?</h2><hr> 
     <div class="col-md-8 col-md-offset-2 w3-margin-bottom"> 
      {!! Form::open(['route' => 'login', 'method' => 'POST']) !!} 
       <div class="form-group {{ $errors->has('email') ? 'has-error has-feedback' : '' }}"> 
        {{ Form::label('email', 'Enter Your Email...', ['class' => 'control-label']) }} 
        {{ Form::email('email', null, ['class' => 'form-control', 'placeholder' => 'email...', 'value' => old('email')]) }} 
        <span class="{{ $errors->has('email') ? 'glyphicon glyphicon-remove form-control-feedback' : '' }}"></span> 
       </div> 
       <div class="form-group {{ $errors->has('password') ? 'has-error has-feedback' : '' }}"> 
        {{ Form::label('password', 'Enter Your Password...', ['class' => 'control-label']) }} 
        {{ Form::password('password', ['class' => 'form-control', 'placeholder' => 'password...']) }} 
        <span class="{{ $errors->has('password') ? 'glyphicon glyphicon-remove form-control-feedback' : '' }}"></span> 
       </div> 
       {{ Form::submit('Log in', ['class' => 'btn btn-success w3-margin-top']) }} 
      {!! Form::close() !!} 
     </div> 
    </div> 
</div> 
<div class="w3-display-container w3-white"> 
    <div style="white-space:nowrap;" class="container"> 
     <h2>New Here?</h2><hr> 
     <div class="col-md-8 col-md-offset-2 w3-margin-bottom"> 
      {!! Form::open(['route' => 'register']) !!} 
       <div class="form-group {{ $errors->has('name') ? 'has-error has-feedback' : '' }}"> 
        {{ Form::label('name', 'Username...', ['class' => 'control-label']) }} 
        {{ Form::text('name', null, ['class' => 'form-control', 'placeholder' => 'username...']) }} 
        <span class="{{ $errors->has('name') ? 'glyphicon glyphicon-remove form-control-feedback' : '' }}"></span> 
       </div> 
       <div class="form-group {{ $errors->has('email') ? 'has-error has-feedback' : '' }}"> 
        {{ Form::label('email', 'Email...', ['class' => 'control-label']) }} 
        {{ Form::email('email', null, ['class' => 'form-control', 'placeholder' => 'email...']) }} 
        <span class="{{ $errors->has('email') ? 'glyphicon glyphicon-remove form-control-feedback' : '' }}"></span> 
       </div> 
       <div class="form-group {{ $errors->has('password') ? 'has-error has-feedback' : '' }}"> 
        {{ Form::label('password', 'Password...', ['class' => 'control-label']) }} 
        {{ Form::password('password', ['class' => 'form-control', 'placeholder' => 'passsword...']) }} 
        <span class="{{ $errors->has('password') ? 'glyphicon glyphicon-remove form-control-feedback' : '' }}"></span> 
       </div> 
       <div class="form-group {{ $errors->has('password') ? 'has-error has-feedback' : '' }}"> 
        {{ Form::label('password_confirmation', 'Confirm Password...', ['class' => 'control-label']) }} 
        {{ Form::password('password_confirmation', ['class' => 'form-control', 'placeholder' => 'confirm password...']) }} 
        <span class="{{ $errors->has('password') ? 'glyphicon glyphicon-remove form-control-feedback' : '' }}"></span> 
       </div> 
       {{ Form::submit('Sign Up', ['class' => 'btn btn-success w3-margin-top']) }} 
      {!! Form::close() !!} 
     </div> 
    </div> 
</div> 

のように見えます。

私が得る問題は、空の入力があるフォームを送信すると、両方のフォームでエラーが発生するということです。
空のメールボックスとパスワードフィールドを使用してログインフォームを送信すると、ログインフォームと登録フォームにそのフィールドが空であることが表示されます。
どうすれば修正できますか? エラーを別の方法で表示したい。
私のコードについて疑問が残っていますか、私の質問は下記にコメントしてください。

私も助けのためthisを見えたが、それは5.2 laravelだった、あなたはそれらの両方のエラーにコードの{{ $errors->has('email') ? 'has-error has-feedback' : '' }}その文字列を示しているので、laravel 5.3は、異なる認証ルートシステム

+0

そのなんとかはあなたでし検証を作成することができ両方の形式でエラーが発生している特定のケースと入力値を伝えます。 –

答えて

1

ザッツを持っているが、レジスタやログインの両方でありますフォームにはエラーが表示されます。

一つの解決策は、あなた自身がそれは少し時間がかかるだろうなどPHP & jQueryの/ JavaScriptを、あなたは完全にエラーをカスタマイズすることができるこの方法を使用して行うことが少し難しいですが、

関連する問題