David Ross
David Ross

Reputation: 197

Laravel withInput not populating form (laravel 4)

I have a form that submits to the controller, but when I add a Redirect::back()->withInput() the input doesn't show.

View:

    <form method="post" action="{{ URL::route('register')}}">
        name:<input type="text" name="name" id="name" /><br/>
        lastName:<input type="text" name="lastname" id="lastname" /> <br/>
        Email:<input type="email" name="email" id="email" /> <br/>
        <input type="submit" value="submit" /><br/>
    </form>

Controller:

 public function postRegister(){
    $validate = Validator::make(Input::all(), array(
        'name' => 'required|min:3',
        'lasatname' => 'required|min:3',
    ));

    if ($validate->fails())
    {
        return Redirect::route('create')->withErrors($validate->messages())->withInput();
    }
    return "success";
}

Upvotes: 1

Views: 107

Answers (1)

Victor
Victor

Reputation: 556

You are not using laravel Form creator. Laravel will only flash input data automatically if you use, for example `Form::text("name"), instead of the actual html code.

If you actually want to keep using the html code instead of the form builder or the blade syntax, you can do so by accessing the input value:

<input type="text" name="name" value="{{ Input::get('name') }}"> as per documentation.

Upvotes: 2

Related Questions