Just a quick bit of advice to those who may have been banging their heads against the walls when trying to pass “form” as a custom parameter in a CakePHP URL. Apparently ‘form’ is a param – an array, to be specific – that’s already set by Cake and using it as a custom parameter won’t work. While finishing up an online email form builder plugin, I defined this route:
Router::connect('/:form/', array('plugin' => 'email_forms', 'controller' => 'email_forms', 'action' => 'view'), array('form' => '[a-z0-9_-]+'));
This didn’t work, however; the route would take me to the correct action, but the ‘form’ param would always be empty – or so I thought. After doing some checking, mostly thanks to the Debug Kit plugin, I realized that the ‘form’ param is passed with every request. So, I just renamed ‘form’ to ‘emailForm’ and it worked like a charm:
Router::connect( '/:emailForm/', array('plugin' => 'email_forms', 'controller' => 'email_forms', 'action' => 'view'), array('emailForm' => '[a-z0-9_-]+'));
So, watch out for those predefined variables.