On Friday, 18 November 2011 13:24:16 UTC+1, Constantin.FF wrote:
>
> I am trying to get page redirected (after add or edit) depending on a 
> field of the form. Here is what I have done so far: 
>
> View: 
> ... 
> $back_link = array('action' => 'browse', $this->Form- 
> >value('Post.parent_id')); 
> echo $this->Form->hidden('redirect_id', array('value' => 
> json_encode($back_link))); 
>

why do you need to json encode the referer(ish) url 

> ... 
>
> Controller: 
> ... 
> $redirect = (array)json_decode($this->data['redirect_id']); 
> $this->redirect($redirect); 
> ... 
>
> When I pr() the $redirect , everything looks just as it should but i 
> get redirected to the browse action without any id after it. 
>

are you sure about that. put it through Router::url and/or check that 
/foo/123 isn't redirecting to /foo 
 

> How to make this working, is it necessary to use separated fields in 
> the view for controller, action, id. Or if you can advise any other, 
> more simple method to do this. 


pass the url as a string (why do array -> encode -> decode -> string, when 
you could simply do array -> string)  - or if you are trying merely to go 
back where you were when the form was submitted - use $this->referer() 
(either directly or by storing the current url in your "go back here" form 
field

AD

-- 
Our newest site for the community: CakePHP Video Tutorials 
http://tv.cakephp.org 
Check out the new CakePHP Questions site http://ask.cakephp.org and help others 
with their CakePHP related questions.


To unsubscribe from this group, send email to
[email protected] For more options, visit this group at 
http://groups.google.com/group/cake-php

Reply via email to