C
C
Caf2016-08-24 10:30:18
Yii
Caf, 2016-08-24 10:30:18

Why aren't rules applied when passed to a url link as a string?

Question out of curiosity.
Rules are written:

'urlManager' => [
    'enablePrettyUrl' => true,
    'showScriptName' => false,
    'rules' => [
        'all' => 'tests/all',
    ],
],

Next, I display links in the template
<?= \yii\helpers\Html::a('Смотреть все тесты', ['tests/all']) ?> <!-- rules работают -->
<?= \yii\helpers\Html::a('Смотреть все тесты', 'tests/all') ?> <!-- rules не работают -->

Why don't the rules work in the second case?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
S
Slava Kryvel, 2016-08-24
@Caf

Html::a() passes the second parameter "url" to the Url::to() method here is the Url
::to() documentation where it says: ... if $url is: ... * a normal string: it will be returned as is. ... Here is the answer to your question)

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question