Hard coding routes.

I’d like to avoid hard coding routes in my views.

I have a controller MaterialsReturnsNoteItemsController.

If I use Url::toRoute([‘index’]) with only an action name, the route is returned as materials-returns-note-items/view. I assume it’s getting the ID of the current controller.

However, if I use Url::toRoute([‘MaterialsReturnsNoteController/index’]) the url is returned verbatim.

I actually would like to target another controller (not the current) in a view - I’d like to call a separate action. So, my question is, how do I find the ID of another controller (in the dashed format controler-name) so I can avoid hard coding in my view button.


Route is always "module/controller/action" or "controller/action" or "action". If there are camelCase parts, these are presented as "camel-case".