F
F
Fet2015-11-05 14:25:12
Laravel
Fet, 2015-11-05 14:25:12

How to save the form attributes of the back to the page field through the browser's Back button click?

Laravel 5 application.
Using Session. Session driver - file.
In the search form 2 selectA. The data in the second one is loaded via ajax after selecting the value in the first one.
The search results are displayed on the next page. When I click on the Home page link - everything is in order, the data is pulled from the session and inserted into the form.
But when I click Back in the browser. Then, only the text input data is pulled up using laravel old('value'), and the selects are empty. If you refresh the page, then the data from the session is inserted.
As I understand it, after pressing the Back button in the browser there is no session? Why are they inserted only after refreshing the page and how can this be fixed.

public function index()
  {
$selected = [
      'auto_brand_id' => Session::get('auto_brand_id'),
      'auto_model_id' => Session::get('auto_model_id')
    ];

        $auto_models = ['' => ''];
        $models = Models_groups::where('brand_id', old('auto_brand_id', $selected['auto_brand_id']))->groupBY('group_name')->orderBY('group_name', 'asc')->get();
        foreach($models as $model){
            $auto_models[$model->group_id] = $model->group_name;
        }
    return view('home', compact('auto_models', 'selected'));
  }

search results
public function for_my_car()
    {
        $input = \Input::all();
        Session::put('search', $input);
        Session::put('auto_brand_id', array_get($input, 'auto_brand_id')); //пишем
        Session::put('auto_model_id', array_get($input, 'auto_model_id')); //пишем
        $searchResult = $this->getSearchResult($input);
        return view('for_my_car', compact('auto_models','searchResult'));
    }

Answer the question

In order to leave comments, you need to log in

2 answer(s)
F
Fet, 2015-11-06
@halenharper

Can be closed.
Problems on the local machine remained. Mac OS 10.10, MAMP. PHP 5.6.2, Laravel 5.0.

J
javanub, 2015-11-05
@javanub

Do you use old in the view in inputs?

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question