tags:

views:

49

answers:

1

I want to use the view for one controller action inside another view with CakePHP, and passing some variables. Anybody has been work on this situation or something similar?

+1  A: 

I think I understand what you're attempting, but I'm pretty sure it's not directly possible - as you've found.

What I tend to do in this situation is find the amount of code I want to replicate in both views, put it in an element and then call $this->renderElement('path-to/element') inside both views.

You could do something with $this->requestAction('controller/function') but it carries a large overhead.

I would suggest considering reformatting your code and using the element suggestion above.

Dave Jones
renderElement() is deprecated (resp. no longer exists in the coming 1.3 release), use element() instead.
dhofstet
Thank you Dave, I'm working in this way. I just work to remove the requestAction because at the end with a few changes I need a form without any previous logic in a controller.
jald