2015-01-07 3 views
1

Laravel 폼이 있습니다. 유효성 검사 양식이 있습니다. 유효성을 검사 할 때 유효성 검사 오류가 있으면 오류가 다시 발생한다고 가정합니다. 그것은 오류를 완벽하게 알려주지 만 필드는 사용자가 작성한 모든 데이터를 잃어 버립니다. 그래서 모든 것은 비어 있습니다. withInput() 기능이이 작업을 수행하지 않아야합니까?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 
+1

보기를 추가 할 수 있습니까 –

+0

dd ($ captcha)하고 결과를 표시 할 수 있습니까? – Ray

+1

@SetKyarWaLar 추가됨 !! – carlosremove

답변

1

.

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

Laravel doc에서 이전 데이터 검색에 대해 자세히 알아보십시오.

+0

Aws! 나는 그것을 깨닫지 못했다. 고마워 정말 고마워. – carlosremove

관련 문제