php - How do i make Laravel "remember" what the user last selected in a drop down menu? -


I am creating a filtering feature in an app that with data input from two (on the same page) The filter will drop down menu I want to "remember" the dropdown that is selected by the user and kept him as a defaults.

  {!! Form :: Open (['method' => gt; 'gET', 'path' => ['path_filter_index']]) !!} {!! Form :: Select ('user', [-1 = & gt; 'all'] + $ users, $ user) !!} {!! Form :: Select ('customer', [-1 = & gt; all '] + $ clients, $ customers] !!} {!! Form :: hidden ('position', 0) !!} {!! Form :: Checkbox ('Status', 1) !!} {!! Form :: submit ('filtrra', ['class' => 'btn btn-primary btn-sm']) !!} {!! Form :: Close () !!}  

Here is a session based solution. In your controller, the submitter data received:

  session :: put ('filter.user', input :: get ('user')); Session :: put ('filter.customer', input :: find ('customer'));  

Then in your view

  {!! Select Form :: Select ('user', [-1 = & '; all'] + $ users, session :: find ('filter.user')) !!} {!! Form :: Select ('customer', [-1 = & gt; 'all'] + $ customers, session :: find ('filter.customer'))}  

Instead, you can also retrieve session values ​​in the view of your controller, and then you can pass them in the

view.

Comments

Popular posts from this blog

HTML/CSS - Automatically set height width from background image? -

php - Mysql Show Process - Sleep Commands and what to do -

c - What is the address of buf (the local variable in the main function)? -