formvalidation middlelwere上的sessioin类

时间:2018-06-19 07:01:03

标签: laravel-5.2

我将使用laravel 5.2使用validatior类执行表单验证当我点击提交按钮时它完美地执行验证但是它不能在输入中显示错误和设置值....

view : @if (count($errors) > 0)
       <div class = "alert alert-danger">
          <ul>
             @foreach ($errors->all() as $error)
                <li>{{ $error }}</li>
             @endforeach
          </ul>
       </div>
    @endif

   {!! Form::open(array('url'=>'admin/display')) !!}
   {!! Form::text('t1') !!}
   {!! Form::submit('Submit') !!}
   {!! Form::close() !!}

路线:

      <?php
            Route::get('/', function () 
            {
                return view('welcome');
            });



Route::post('admin/display',['middleware'=>'web','uses'=>'admin@display']);

控制器:

    <?php

    namespace App\Http\Controllers;

    use Illuminate\Http\Request;
    use App\Http\Requests;
    //use Illuminate\Support\Facades\Input;
    use validator;

    class admin extends Controller
    {


    public function display(Request $r)
    {
    $this->validate($r,array('t1' => 'required|alpha'));

    echo $r->t1;
    }


    }

0 个答案:

没有答案