Account Options

  1. Sign in
The old Google Groups will be going away soon, but your browser is incompatible with the new version.
Google Groups Home
« Groups Home
Message from discussion Routes with optional parameters
The group you are posting to is a Usenet group. Messages posted to this group will make your email address visible to anyone on the Internet.
Your reply message has not been sent.
Your post was successful
 
From:
To:
Cc:
Followup To:
Add Cc | Add Followup-to | Edit Subject
Subject:
Validation:
For verification purposes please type the characters you see in the picture below or the numbers you hear by clicking the accessibility icon. Listen and type the numbers you hear
 
lowpass  
View profile  
 More options Nov 7 2012, 1:42 pm
From: lowpass <zijn.digi...@gmail.com>
Date: Wed, 7 Nov 2012 13:40:35 -0500
Local: Wed, Nov 7 2012 1:40 pm
Subject: Re: Routes with optional parameters
I think changing the regexp from + to ? in the first route would do it.

        Router::connect(
                '/open-account/:id',
                array(
                        'controller' => 'users',
                        'action' => 'add'
                ),
                array(
                        'pass' => array('id'),
                        'id' => '[a-z]?'
                )
        );

On Wed, Nov 7, 2012 at 11:00 AM, Jeremy Burns

<jeremybu...@classoutfit.com> wrote:
> How do I set up a route that sometimes has a parameter and sometimes
> doesn't? For example, I have the following two routes but I'm sure they
> could be combined into one?

> Router::connect(
> '/open-account/:id',
> array(
> 'controller' => 'users',
> 'action' => 'add'
> ),
> array(
> 'pass' => array('id'),
> 'id' => '[a-z]+'
> )
> );

> Router::connect(
> '/open-account',
> array(
> 'controller' => 'users',
> 'action' => 'add'
> )
> );

> --
> Like Us on FaceBook https://www.facebook.com/CakePHP
> Find us on Twitter http://twitter.com/CakePHP

> ---
> You received this message because you are subscribed to the Google Groups
> "CakePHP" group.
> To post to this group, send email to cake-php@googlegroups.com.
> To unsubscribe from this group, send email to
> cake-php+unsubscribe@googlegroups.com.
> Visit this group at http://groups.google.com/group/cake-php?hl=en.


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.