Hello everyone!
I’ve faced such a problem with generating links for my module views
Problem
While being on a page
/rights-manager-dev/roles/create
I try to create link to
rights-manager-dev/permissions
Tried:
Url::toRoute('permissions') // Result is "/rights-manager-dev/roles/permissions"
Try #2
Url::toRoute('/permissions') // Result is "/permissions"
Solution
Ok. I dived into the \yii\helper\Url code and discovered, that folowing code solves my problem:
Url::toRoute('permissions/') // Result is "/rights-manager-dev/permissions"
This happens because of \yii\helpers\Url::normalizeRoute($route) protected static function.
I attach an image with explanation
Question
Defining route as “permissions/” looks strange to me.
Is it supposed to be so, when using modules? Or am I missing smth?
How should one use \yii\helpers\Url correctly inside a module?
Thank you!