I followed this tut (copy of this) for creating custom rule for named parameters. In my rules array i've added 2 upper lines to parse backwards and forwards Assortment[groupCategory]
parameter.
'urlManager'=>array(
'showScriptName'=>false,
'urlFormat'=>'path',
'rules'=>array(
'assortment/<Assortment[groupCategory]:\d+>'=> 'assortment/index',
'assortment/<Assortment%5BgroupCategory%5D:\d+>'=> 'assortment/index',
'<controller:\w+>/<action:\w+>/<id:\d+>'=>'<controller>/<action>',
'<controller:\w+>/<action:\w+>'=>'<controller>/<action>',
),
),
This works forward:
with http://tarex.ru/assortment/index/Assortment[groupCategory]/1
the yii recognize Assortment[groupCategory]
as a GET parameter equal 1.
But if from a form i request
http://tarex.ru/assortment/index?Assortment[groupCategory]=2
orhttp://tarex.ru/assortment/index?Assortment%5BgroupCategory%5D=2
it does not transform it into the human readable ulr, like this:
http://tarex.ru/assortment/index/Assortment[groupCategory]/2
Why? The tut sais it's two-way url manager.
On the other hand, when creating a URL with the route post/index and parameter tag, the urlManager component will also use this rule to generate the desired URL /index.php/posts/yii. For this reason, we say that urlManager is a two-way URL manager.
Yes, Yii does not transform url in browsers address bar, nor in forms action parameter. Everything is run „behind scenes“.
I recommend you to rewrite your rule
to
In this way, if you go to url
http://tarex.ru/assortment/index/1
anactionIndex()
method will be called in controller namedAssortmentController
. And parameter$groupCategory = 1
will be passed to it. To handle passed variable you probably need to change methods signature to:The „back-way“ will be if you create url by getting parameters in this way:
a url
/assortment/index/1
must be created.