Ticket #496 (closed Bug: fixed)
Router prevents optional arguments from getting set to their default values.
| Reported by: | atomless | Owned by: | Geert |
|---|---|---|---|
| Priority: | critical | Milestone: | 2.1.2 |
| Component: | Libraries | Version: | SVN HEAD |
| Keywords: | Router arguments | Cc: |
Description
in short: the kohana router prevents optional arguments from getting set to their default values.
in detail:
If I add a route to my application routes config like so:
$config['testmethod'] = 'maincontroller/testmethod/';
as expected the url http://mydomain.com/testmethod is successfully routed to the testmethod within maincontroller -
if I also add this to the routes config:
$config['testmethod/(.+)'] = 'maincontroller/testmethod/$1';
then arguments passed to the testmethod via the url like so: http://mydomain.com/testmethod/arg1/arg2 are also successfully passed as arguments to the testmethod within maincontroller.
However, if the test method has a default setting for an optional argument like so:
public function testmethod($optionalarg1='foo')
optionalarg1 does not get set to the default value when the url has no arguments
optionalarg1 will always simply equal FALSE with the url http://mydomain.com/testmethod/
whereas bypassing the router like so http://mydomain.com/maincontroller/testmethod/ optionalarg1 will equal 'foo'
