Kohana 3.2 Route::get-Collection of common programming errors

I’m trying to add simple links in kohana inside a view inside a loop .

Here is the code i have :

echo HTML::anchor(Route::get('parent')->uri(array('id' => $parent->id)), HTML::chars($parent->email))

Now this return a link to root because

Route::get('parent')->uri(array('id' => $parent->id)

returns an empty string .

Now if If i modify my Route::get to :

Route::get('parent')->uri(array(
                      'controller' => 'parent' , 
                      'action'     => 'index'  , 
                      'id'         =>  $parent->id))

I get the correct link .

Question : Why Kohana is not able to get the correct link knowing that in my bootstrap i have the following :

Route::set('parent', '((/(/)))')
->defaults(array(
'controller' => 'parent',
'action'     => 'index',
));

And that : Route::get(‘parent’) returns :

: object(Route) = 
  _callback: undefined = NULL
  _uri: string = "((/(/)))"
  _regex: array = 
  _defaults: array = 
    controller: string = "parent"
    action: string = "index"
  _route_regex: string = "#^(?:(?P[^/.,;?\\n]++)(?:/(?P[^/.,;?\\n]++)(?:/(?P[^/.,;?\\n]++))?)?)?\$#uD"
  1. Due to Kohana 3.2 doc (http://kohanaframework.org/3.2/guide/api/Route#uri) Route::uri() method Generates a URI for the current route based on the parameters given.. So if you want this to work you have to define ALL the route parameters.

Originally posted 2013-11-27 11:52:59.