phpzend-frameworkzend-routezend-router

Zend Framework multi-word action names


This question has been asked many times but for some reason the proposed solution isn't working for me.

I wan't to use names like "deleteDefaultUser" for my action. To achieve this I have done following.

Added a route

$route = new Zend_Controller_Router_Route_Static(
                'user/delete-default-user',
                array(
                        'action'     => 'deleteDefaultUser',
                        'controller' => 'user',
                        'module'     => 'root'
                )
        );
        $router->addRoute('delete-default-user', $route);

Defined my action as below

public function deleteDefaultUserAction(){
        //some code
    }

And generated a URL like this

 echo  $this->url(array(), 'delete-default-user');

( This generates the URL /user/delete-default-user)

But for some reason I am still getting the error shown below:

Zend_Controller_Action_Exception: Action "deletedefaultuser" does not exist and was not trapped in __call() in C:\Users\Jay\Projects\EOP\library\Zend\Controller\Action.php on line 485

I have checked the controller and action names are correct. But from the error message it seems that Zend Framework is not applying camel case to action names.

The version of Zend Framework that I am using is 1.12.

Can any one please help with this?

Edit: If I change my action name to 'deletedefaultuser' it works correctly.


Solution

  • Change the action part of the route to:

    'action'     => 'delete-default-user',
    

    and then it should work.