On Apr 20, 4:23 pm, tersmitten <[email protected]> wrote:
> Is it possible to use both the `expression` validation and `pass key`
> in one route? I would like to do something like:
>
> Router::connect(
> '/events/index/:year-:month-:day',
> array(
> 'controller' => 'events',
> 'action' => 'index',
> ),
> array(
> 'year' => $Year,
> 'month' => $Month,
> 'day', $Day,
> 'pass' => array('year', 'month', 'day')
> )
> );
>
> But if I visit /events/index/2010-04-1434, 2010-04-1434 is passed to
> the controller while it's not a valid `day` I would say. What I'm
> trying to do is both `url validation` and `easy passing`. Is this
> possible, and how?
Use these regexps:
Router::connect(
'/events/:year/:month/:day,
array(
'controller' => 'events',
'action' => 'index'
),
array(
'year' => '2[0-9]{3}',
'month' => '0[1-9]|1[012]',
'day' => '0[1-9]|1[0-9]|2[0-9]|3[01]',
'pass' => array('year', 'month', 'day')
)
);
function index($year = null, $month = null, $day = null)
{
...
This way, you do not need 'index' in the URL.
Check out the new CakePHP Questions site http://cakeqs.org and help others with
their CakePHP related questions.
You received this message because you are subscribed to the Google Groups
"CakePHP" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected] For more options, visit this group at
http://groups.google.com/group/cake-php?hl=en