action is in a different controller.
On Apr 2, 6:15 pm, nurvzy <nur...@gmail.com> wrote:
> I agree, routes are the way to go in this senario. But you may also
> benefit from setAction();
> setAction doesn't preform a redirect, instead it just executes the
> said action instead. This means $this->data and $this->params are
> not reset as its all in the same request.
>
> An example:
> //some_controller.php
> function some_action(){
> if($some_condition){
> $this->setAction('real_action');
> }
>
> }
>
> function real_action(){
> debug($this->data);
>
> }
>
> if $some_condition is true, the action is then "redirected" (but in
> the same request) to real_action(). You can also pass parameters
> into it:
> $this->setAction('action_name_you_want', $parameters);
>
> Here's the API:http://api13.cakephp.org/class/controller#method-ControllersetAction
>
> Hope that helps,
> Nick
>
> On Apr 2, 12:11 pm, cricket <zijn.digi...@gmail.com> wrote:
>
> > Put it in app/config/router.php
>
> > On Apr 2, 1:19 pm, mivogt-LU <c...@mivogt.net> wrote:
>
> > > hi cricket and thanks a lot.
> > > sadly I never did a router before
> > > so I ask if you might tell me how and where to do so.
>
> > > thanks in advance
>
> > > michael
>
> > > On 2 Apr., 18:24, cricket <zijn.digi...@gmail.com> wrote:
>
> > > > On Apr 2, 11:38 am, mivogt-LU <c...@mivogt.net> wrote:
>
> > > > > ok i solved one part of it - so I can redirect to the bookings add
> > > > > function.
>
> > > > There's no need for a redirect from RequestsController. Just have your
> > > > button point to "/bookings/add/THE_REQUEST_ID" in the first place. You
> > > > may want to create a route:
>
> > > > Router::connect(
> > > > '/bookings/add/:request_id',
> > > > array('controller' => 'bookings', 'action' => 'add'),
> > > > array('request_id' => '[0-9]+', 'pass' => array('request_id'))
> > > > );
>
> > > > > but I am not shure about how to send data to the target.
>
> > > > > Is it useful and a good idea to use something like adding a '?
> > > > > customer_id=123,?booking_id=456" ??
>
> > > > function add($request_id = null)
> > > > {
> > > > $request_data = $this->Booking->Request->find(
> > > > 'first',
> > > > array(
> > > > 'condtions' => array(
> > > > 'Request.id' => $request_id
> > > > )
> > > > );
>
> > > > // die(debug($request_data));
> > > > ...
>
> > > > }
>
> > > > This is assuming that Request data will include that for Customer.
> > > > Check the debug output.
>
>
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 cake-php@googlegroups.com
To unsubscribe from this group, send email to
cake-php+unsubscribe@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php?hl=en
To unsubscribe, reply using "remove me" as the subject.
No comments:
Post a Comment