In order to passedArgs to work as you described, do they still need to
be declared in
Router:::connectNamed ? I have had troubles with args, but few months
ago ...
Cheers
On Nov 15, 12:01 am, Grant Cox <[EMAIL PROTECTED]> wrote:
> Any parameters that are optional should be done with named parameters,
> ie
>
> /your/action/id:123/parent:32
>
> in your action just look at $this->passedArgs['id'] and
> $this->passedArgs['parent']. These do not interfere with required
>
> parameters, and can be in any order. For example, given the action
>
> function edit( $id=null ){
> $this->log( $this->passedArgs['parent'] );
> $this->log( $this->passedArgs['sibling'] );
>
> }
>
> you could access via
> /controller/edit/1
> /controller/edit/1/parent:123/sibling:432
> /controller/edit/sibling:432/parent:123/1
>
> and all would have the $id = 1
>
> On Nov 15, 2:51 am, kgrimm <[EMAIL PROTECTED]> wrote:
>
> > thanks for your help, then I will change the order of the parameters.
> > I had this idea too, but it means I'll have to change quite a few
> > pieces of existing code, and I'm always afraid of missing some.
>
> > On Nov 14, 5:40 pm, francky06l <[EMAIL PROTECTED]> wrote:
>
> > > Pass this as the second parameter of your url, then you can default
> > > your second parameter to null in the controller. Of course this if you
> > > are not doing the same for the $part2 already ..
> > > Otherwise create another method in controller that calls an internal
> > > method (to handle both cases).
>
> > > On Nov 14, 5:37 pm, kgrimm <[EMAIL PROTECTED]> wrote:
>
> > > > actually that won't help, because I need to make a difference between
> > > > null and 0 (0 in this case means to create a new table row). My
> > > > current solution is to pass a fixed value that has no other meaning,
> > > > e.g. -1, and set the parameter to null in the controller function if
> > > > it equals it. But I don't like it that way, so I just wondered if
> > > > there's a possibility to pass 'null'.
>
> > > > On Nov 14, 5:31 pm, francky06l <[EMAIL PROTECTED]> wrote:
>
> > > > > you can pass 0, in your controller you can check if($part1) for
> > > > > example
>
> > > > > On Nov 14, 5:28 pm, kgrimm <[EMAIL PROTECTED]> wrote:
>
> > > > > > Hi,
>
> > > > > > how can I pass null values to a controller function using its URL?
>
> > > > > > for example: "controller/function/par1/par2", how can I make par1
> > > > > > null?
>
> > > > > > Thanks in advance!
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Cake
PHP" 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
-~----------~----~----~----~------~----~------~--~---