Created
February 13, 2012 23:24
-
-
Save jboesch/1821407 to your computer and use it in GitHub Desktop.
cakephp 2.0 plugin re-routing problems
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<? | |
// routes.php | |
Router::connect('/animals/:action/*', array( | |
'plugin' => 'big', | |
'controller' => 'BigAnimalsController' | |
)); | |
/* | |
* Now I navigate to /animals and I look at my action attribute on my <form> tag | |
* How come my $form->create(array('controller' => 'animals')); call still outputs: | |
* /big/animals instead of /animals | |
* as the action? | |
*/ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
A couple of reasons:
$form->create(array('controller' => 'animals'));
is incorrect. The 1st param of the$this->Form->create()
should be the Model name. Cake is simply defaulting to the controller/action it is being called from. You should do this instead:$this->Form->create('BigAnimal', array('url' => array('controller' => 'big_animals'));
BigAnimalsController
it should simply bebig_animals
. Your Router::connect should be:Router::connect('/animals/:action/*', array('plugin' => 'big', 'controller' => 'big_animals'));