lyl0o0o
lyl0o0o

Reputation: 420

Laravel4 Repopulate Search Form after submit

I have a get method search form with a field like this:

{{  Form::text("name", null, array('class' => 'form-control'))  }}

My controller look like this:

public function index()
{
    ...
    $result= $this->repo->search($data, $page, $perPage);
    return View::make('index', compact('result'));
}

The route look like this:

Route::get('/search', 'controller@index');

and the form:

<form action="/search" id="searchForm" class="search-form">

I want to repopulate the name field to keep his value even after the search submit.

To do this I added to my controller before the view::make:

Input::flash();

I have problems with this flashing, because when I open one of my result line from the search for editing, the old input is not empty and cause false values on the form model binding of this editing page.

How can I repopulate the search form in an other way ? (No model binding possible for this search form)

Upvotes: 2

Views: 181

Answers (1)

lyl0o0o
lyl0o0o

Reputation: 420

Finally, I found what I was searching:

{{  Form::text("name", Input::get("name"), array('class' => 'form-control'))  }}

With all the magical in Laravel, I thought there is a possibility to do this automatically, but this what I was searching.

Upvotes: 1

Related Questions