Composite Primary Key and UrlManager

Hi there,

It seems that my yii does not like composite primary keys in models.

I use an array of strings for my composite primary keys as explained in doc, but I have a 400 error (that’s an urlmanager error right?)

I use it with GridView, CButtonColumn and an url issue update like :


array('class'=>'CButtonColumn','viewButtonUrl'=>'Yii::app()->controller->createUrl("view",$data->primaryKey)',

        'updateButtonUrl'=>'Yii::app()->controller->createUrl("update",$data->primaryKey)',

        'deleteButtonUrl'=>'Yii::app()->controller->createUrl("delete",$data->primaryKey)',)

So, my buttons links look like :


(...)index.php?r=<controller>/view&<id_1>=<id_1_value>+&<id_2>=<id_2_value>

(understand that ‘<’ chars are ‘generic’ and not present in the url).

I use no UrlManager ‘override’ in the main.php (so I use default features).

Could you help me?

Many thanks

Parameter names in your view/update/delete action method must match the names of GET parameters.

Gii (if used) generates something like this:


public function actionView($id) {...}

It has to be changed to:


public function actionView($id_1, $id_2) {...}

Thank you for your answer.

Could you please tell me how can I show data with composite primary key in CGridView ???

Helps highly appriciate

I just wrote this little piece of info today. May be of assistance. I know it is an old question though… sorry.

http://evileyegames.com/article/42-generating-urls-composite-keys-yii-framework