php - Laravel3 how to send variable into controller from view -


i'm learning laravel 3 @ moment, , have technical question. have list of authors , i'm trying make links set filter order authors.

i tried setting default parameters order name, works, can't pass other filters.

this route :

route::get('authors', array('as'=>'authors', 'uses'=>'authors@index')); 

and controller function :

public function get_index($filter="name"){     return view::make('authors.index')         ->with('title', 'authors list')         ->with('authors', author::order_by($filter)->get()); } 

and links in view trying send filter want

{{ html::link_to_route('authors', 'id', array('id')) }} {{ html::link_to_route('authors', 'name', array('name')) }} 

the parameters try send (id , name) view never reach controller use default parameter.

thank !

you're not setting route parameters, must like:

route::get('authors/(:any?)', array('as'=>'authors', 'uses'=>'authors@index')); 

take @ docs: http://three.laravel.com/docs/routing#wildcards


Comments

Popular posts from this blog

html - How to style widget with post count different than without post count -

How to remove text and logo OR add Overflow on Android ActionBar using AppCompat on API 8? -

javascript - storing input from prompt in array and displaying the array -