Tuesday, January 25, 2022

[FIXED] Can you call a controller function from a view in CakePHP?

Issue

I want to call a controller function from a view. Is that possible in Cake PHP?


Solution

It is possible via the requestAction method, but it is not recommended due to a slight performance hit. Use it wisely.

As Xr noted in the comment, using requestAction often signifies design issues (MVC separation).



Answered By - dr Hannibal Lecter

No comments:

Post a Comment

Note: Only a member of this blog may post a comment.