提问者:小点点

使用Laravel 4+3引导程序验证后保持模态并显示错误


阅读文章:keep modal open after validation redirectionenable在验证后立即打开modal框,但是,显示没有发生错误,只显示表单,我相信这是因为该操作再次调用jquery表单,因为我使用的是远程函数bootstrap 3 modal。

解决方法提示,请在模式窗口中显示错误。

控制器:

if ($validacao->fails()) :
   $input = Input::all();
   $input['autoOpenModal'] = true;
   return Redirect::back()->withErrors($validacao)->withInput($input);
endif;

模态形式:

<div>
   {{ Form::label( 'inputEmail1', 'Email', array( 'class' => 'col-lg-2 control-label' ) ) }}
   <div>
      {{ Form::email( 'email', '', array( 'class' => 'form-control', 'placeholder' => 'Email' ) ) }}
      {{ $errors->first('email', '<p class="help-block text-danger">:message</p>') }}
   </div>
</div>

Jquery操作:

<script type="text/javascript">
   if ({{ Input::old('autoOpenModal', 'false') }}) {
      $('#remoteModal').modal({show: true, remote: '{{ URL::to('users/inserir') }}'});
   }
</script>

我认为这个远程端正在加载引导模式,就像一个新调用一样,因此他的$errors->first()没有显示任何内容。

谢谢你的帮助


共1个答案

匿名用户

你不需要在这里做任何远程提取。窗体已存在于页面的模态中。

正如您所关注的帖子所说:

    if ({{ Input::old('autoOpenModal', 'false') }}) {
        //JavaScript code that open up your modal.
        $('#remoteModal').modal('show');
    }