Php withInput()不返回数据

Php withInput()不返回数据,php,laravel,laravel-4,Php,Laravel,Laravel 4,我有一张拉威尔表格。它有一个验证表单。当它进行验证时,如果存在验证错误,则假定它会返回错误。它告诉perfect错误,但字段会丢失用户写入的所有数据。所以一切都是空的。withInput()函数不应该执行此任务吗 我会把我的控制器写在这里,如果你还需要什么,告诉我 $validate = Validator::make(Input::all(), array( 'firstname' => 'required', 'lastname' => 'required

我有一张拉威尔表格。它有一个验证表单。当它进行验证时,如果存在验证错误,则假定它会返回错误。它告诉perfect错误,但字段会丢失用户写入的所有数据。所以一切都是空的。
withInput()
函数不应该执行此任务吗

我会把我的控制器写在这里,如果你还需要什么,告诉我

$validate = Validator::make(Input::all(), array(
      'firstname' => 'required',
      'lastname' => 'required',
      'email1' => 'required|email',
      'email2' => 'required|same:email1',
      'password1' => 'required|min:6',
      'password2' => 'required|same:password1',
      'g-recaptcha-response' => 'required|recaptcha',
    ));
    $captcha=Input::get('g-recaptcha-response');
   //CAPTCHA CODE

    if ($validate->fails())
    {
      return Redirect::route('getApplication')->withErrors($validate)->withInput();
    }
我在这里的观点是,因为您要求:

@extends('templates.default.master')

@section('head')
@parent
<title>Application</title>
<script src='https://www.google.com/recaptcha/api.js'></script>
@stop

@section('content')
  <form role="form" method="post" action="{{ URL::route('postApplication') }}">

    <div class="form-group col-xs-6 {{ ($errors->has('firstname')) ? ' has-error' : '' }}">
      <label for="firstname">First Name</label>
      <input id="firstname" name="firstname" type="text" class="form-control">
      @if($errors->has('firstname'))
        {{ $errors->first('firstname') }}
      @endif
    </div>

    <div class="form-group col-xs-6 {{ ($errors->has('lastname')) ? ' has-error' : '' }}">
      <label for="lastname">Last Name</label>
      <input id="lastname" name="lastname" type="text" class="form-control">
      @if($errors->has('lastname'))
        {{ $errors->first('lastname') }}
      @endif
    </div>

    <div class="form-group col-xs-6 {{ ($errors->has('email1')) ? ' has-error' : '' }}">
      <label for="email1">Email</label>
      <input id="email1" name="email1" type="text" class="form-control">
      @if($errors->has('email1'))
        {{ $errors->first('email1') }}
      @endif
    </div>

    <div class="form-group col-xs-6 {{ ($errors->has('email2')) ? ' has-error' : '' }}">
      <label for="email2">Confirm Email</label>
      <input id="email2" name="email2" type="text" class="form-control">
      @if($errors->has('email2'))
        {{ $errors->first('email2') }}
      @endif
    </div>

    <div class="form-group col-xs-6 {{ ($errors->has('password1')) ? ' has-error' : '' }}">
      <label for="passsword1">Password</label>
      <input id="password1" name="password1" type="password" class="form-control">
      @if($errors->has('password1'))
        {{ $errors->first('password1') }}
      @endif
    </div>

    <div class="form-group col-xs-6 {{ ($errors->has('password2')) ? ' has-error' : '' }}">
      <label for="passsword2">Confirm Password</label>
      <input id="password2" name="password2" type="password" class="form-control">
      @if($errors->has('password2'))
        {{ $errors->first('password2') }}
      @endif
    </div>

    <div class="g-recaptcha col-xs-12" data-sitekey="6LeQAgATAAAAAAfJ-blWgKvb5-rUyp9xuo-iCdF9"></div>
    <div class="form-group col-xs-12">
      @if($errors->has('g-recaptcha-response'))
        {{ $errors->first('g-recaptcha-response') }}
      @endif
    </div>

    {{ Form::token() }}

    <div class="form-group col-xs-12">
      <input type="submit" value="Submit Application" class="btn btn-success">
    </div>
  </form>

@stop
@extends('templates.default.master')
@第节(“标题”)
@母公司
应用
@停止
@节(“内容”)
名字
@如果($errors->has('firstname'))
{{$errors->first('firstname')}
@恩迪夫
姓
@如果($errors->has('lastname'))
{{$errors->first('lastname')}
@恩迪夫
电子邮件
@如果($errors->has('email1'))
{{$errors->first('email1')}
@恩迪夫
确认电子邮件
@如果($errors->has('email2'))
{{$errors->first('email2')}
@恩迪夫
密码
@如果($errors->has('password1'))
{{$errors->first('password1')}
@恩迪夫
确认密码
@如果($errors->has('password2'))
{{$errors->first('password2')}
@恩迪夫
@如果($errors->has('g-recaptcha-response'))
{{$errors->first('g-recaptcha-response')}
@恩迪夫
{{Form::token()}}
@停止

例如,您需要检索所有输入值中的旧数据

<input type="text" name="firstname" value="{{ Input::old(firstname) }}">


阅读有关在Laravel上检索旧数据的更多信息。

您可以添加视图吗可以添加($captcha)并显示结果吗?@SetKyarWaLar Added@雷,为什么?验证码工作正常!我没有意识到这一点。谢谢,我真的很感激。