M
M
Mykola2017-06-21 19:52:08
Yii
Mykola, 2017-06-21 19:52:08

Why does Yii2 generate invalid named URls?

Subject. Has Url rules

'rules' => [
  'room/<room_id:\d+>/calendar' => 'calendar/view',
  'room/<room_id:\d+>/calendar/<month:\d+>/<year:\d+>' => 'calendar/view',
],

and there is Url generation
Url::to(['calendar/view', 'room_id' => $this->room_id, 'month' => $month, 'year' => $year]);

The URL will look like this:
/room/1/calendar?month=06&year=2017

Should be /room/1/calendar/06/2017
Why and how to fix it?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
M
Maxim Timofeev, 2017-06-21
@iSensetivity

Because 1 rule works, not the second. You should leave 1 or try to change their order

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question