CGridView and variables in rows


I need a pop-up launched from a CGridView that allows entry of a single number. That will create a record in a many-to-many table that is loosely related to the data in the CGridView, and the value I’m after (for the parent) is not available through relations.

Is it possible to get the value from an unrelated model into a CGridView row? OR, how can I add a single key to a CActiveDataProvider and have it accessible from the row of a CGridView? OR, better yet, how can I simply pass a PHP variable into a function of a CButtonColumn?

A stripped down example in the View:

$variable = 1234;







        'viewButtonUrl'=>'Yii::app()->createUrl("/myController/view", array("id"=>$data->functionThatReturnsAnId($variable))'

Results in:

PHP Error

Undefined Variable: variable

Is it just a simple syntax error?

Thank you!


$variable is declared outside of the scope that renders the data

Wow. Just like that, eh Gustavo? I’m humbled and thank you very much for your help!!! :D

Glad I could help, rums

Do you still have any doubt tho ?