Love Fuel?
Donate
About
Forums
Discussions
Login
FuelPHP Forums
Ask your question about FuelPHP in the appropriate forum, or help others by answering their questions.
General
Trouble with an optional named route parameter
Alexandr
October 2013
Hi all!
I try to use a following route rule:
'timetables/edit/:id(/:month)' => array('timetable/edit', 'name'=>'timetables_edit')
But, if I go to
http://xxx/timetables/edit/5
URL I get an error
404
- Page not found
But
http://xxx/timetables/edit/5/2
URL is working.
If I edit the rule:
'timetables/edit/:id(/:month)?' => ...
then both
http://xxx/timetables/edit/5
and
http://xxx/timetables/edit/5/2
URLs are working.
The '?' is really necessary?
As far as I know parenthesisses make the named parameter optional. Am I wrong?
Harro
October 2013
Accepted Answer
No, the brackets just mean you can refer the it in the target using $1. It's compiled into a standard regex, so you do need to question mark to make it optional.
Alexandr
October 2013
@
Harro Verton
Thank you for you answer!
Add a Comment
Howdy, Stranger!
It looks like you're new here. If you want to get involved, click one of these buttons!
Sign In
Apply for Membership
Categories
All Discussions
5,088
General
↳ General
3,364
↳ Job Board
13
↳ Installation & Setup
214
Packages
↳ Oil
213
↳ Orm
700
↳ Auth
260
Development
↳ Tips and Tutorials
126
↳ Code share
145
↳ Applications
52
In this Discussion
Alexandr
October 2013
Harro
October 2013