I use framework Yii2.

In the configuration, there is a rule for UrlManager:

.... 'components' => [ ... 'urlManager' => [ 'enablePrettyUrl' => true, 'showScriptName' => false, 'rules' => [ ... [ 'pattern' => '<some-param>/some-page', 'route' => 'some/route', 'defaults' => ['some-param' => 'default-value'] ], ... ] ], ... ] .... 

In the code, this route is used in many places: echo Html :: a ('Some page', ['some / route']);

But instead of forming a link with the default parameter: default-value / some-page, the wrong link is formed: some / route

Question: Why can defaults be written in the rules if they are not substituted when forming links?

According to the idea of ​​defaults, the values ​​for this and are needed, that if somewhere in the formation of the link the parameters are not specified, then it is necessary to set the default values.

    1 answer 1

    Roules are handled correctly. By default, it does not display routes

    http://www.yiiframework.com/doc-2.0/guide-runtime-routing.html#parameterizing-routes

    We need to make another rule for default routes.