We have moved our forum to GitHub Discussions. For questions about Phalcon v3/v4/v5 you can visit here and for Phalcon v6 here.

How to set action in the current router in the url?

how to put action as a parameter in the url?

example:

router:

 $this->add (
            '/controller/:action/:int/:params',
            array (
                'action' => 1,
                'id'     => 2,
            )
        )
        ->setName ( 'Router' );

volt:

{{ url(['for': 'Router',  'action':'index', 'id':51 ]) }}

return localhost/controller//51



2.8k
Accepted
answer
edited Aug '16

I found the error, the router comes into conflict with arguments that have default numeric..

exemplo

 $this->add (
            '/controller/:action/:int/:params',
            array (
                'action' => 1,
                'id'     => 2,
                'page' => 1 //value default 1 conflicts with action 1
            )
        )
        ->setName ( 'teste' );