在laravel 5.3中验证bootstrap模态形式

时间:2017-08-18 16:20:31

标签: php laravel-5.3

我正在尝试验证模态表单。我希望错误显示在模态而不是模态关闭。请问我该怎么做?

这是我的观点

<div class="modal fade" id="{{$item->id}}" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
   <div class="modal-dialog">
       <div class="modal-content">
         <form action = "{{url('requests/rfq/send')}}" method="post" class="bootstrap-modal-form">  
            <div class="modal-body">
                <input type="text" name="name">
            </div>
            <div class="modal-footer">
              <a class="btn btn-default btn-ok" data-dismiss="modal">Cancel</a>
             <input type="submit" value="submit"  class="btn btn-danger">
           </div>
      </form>
     </div>
  </div>
</div>

我的控制器

public function send_rfq(Request $request){
        $validator = Validator::make($request->all(), [
            'name' =>'required'
        ]);
        if($validator->fails()){
            return back()
                ->withErrors($validator)
                ->withInput();
        }
    }

0 个答案:

没有答案