I am making my own cakephp 2 plugin called Rma and for this plugin I made some routes. When I want to make a form linking to the edit page, the link is different from the link in my routes file. In the browser are my routes working, but cakephp generate different links when I change form actions or echo the Html Link.
The code echo $this->Html->url(array('plugin' => 'Rma', 'controller' => 'RmaRequests', 'action' => 'edit', 2));
gives me the following url: '/Rma/RmaRequests/edit/2' while the url in the routes file is
'/rma/edit/:id'. Cakephp gives me the wrong url.
This is my routes.php in the plugin config folder (app/Plugin/Rma/Config/routes.php):
Router::connect('/rma/new', [
'plugin' => 'Rma',
'controller' => 'RmaRequests',
'action' => 'add'
]);
Router::connect('/rma/edit/:id', [
'plugin' => 'Rma',
'controller' => 'RmaRequests',
'action' => 'edit'
],
array(
// order matters since this will simply map ":id" to
// $articleId in your action
'pass' => array('id'),
'id' => '[0-9]+'
));
Router::connect('/rma/new/:id/', array(
'plugin' => 'Rma', 'controller' => 'RmaRequestProducts', 'action' => 'add'),
array(
// order matters since this will simply map ":id" to
'pass' => array('id'),
'id' => '[0-9]+'
)
);
I've also tried to place the route in my application routes.php, but that still doesn't solve the problem.
This is the way how I load my plugin in app/Config/bootstrap.php:
CakePlugin::load('Rma', array('routes' => true, 'bootstrap' => true));
Is there something I forgot or something that I did wrong? I am using CakePHP version 2.5.1
/:controller/:action/*
. – ndmRouter::connect
), and show them all if you can't figure it out. – ndm'id' => 2
in your URL array, not just2
. – ndm