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 name .volt based on controller's action with two or more words?

Dear experts,

How to rename .volt based on controller's action with two or more words?

Calling mydomain.com/product-purchase/create-new shows nothing :(

My routes

$router = new Phalcon\Mvc\Router(false);

$router->add('/([a-z\-]+)', array(
      'controller' => 1
));

$router->add('/:controller/([a-zA-Z\-]+)/:params', array(
    'controller' => 1,
    'action' => 2,
    'params' => 3
))->convert('action', function($action) {
    return Phalcon\Text::camelize($action);
});

My controller

public class ProductPurchaseController
{
    public function createNewAction()
    {

    }
}

I've managed to call createNewAction successfully by direct echo "Hello world", but not with a volt views.

In my views folder, I've tried:

productPurchase/createNew.volt

productpurchase/createnew.volt

productpurchase/createNew.volt

None of them works :(

What is actually .volt filename should be?

Thank you so much for the help.

Jim

Use product_purchase/createnew.volt

Took me a while to work that one out.

@rebelmiles Wow, that's works with disable routing.

One question, how to make this work with route also? Do you have any ideas?

I'm stuck to make createNewAction() found my create-new.volt :(

Thank you

Which router are you using?

And are you enabling defaults?

My router looks like this:

$router = new Phalcon\Mvc\Router(false);

$router->add('/([a-z\-]+)', array(
      'controller' => 1
));

$router->add('/:controller/([a-zA-Z\-]+)/:params', array(
    'controller' => 1,
    'action' => 2,
    'params' => 3
))->convert('action', function($action) {
    return Phalcon\Text::camelize($action);
});