YiiBooster icon indicating copy to clipboard operation
YiiBooster copied to clipboard

TbToggleColumn $data->primaryKey is not working

Open Jay0Wei opened this issue 7 years ago • 0 comments

$data->primaryKey is null when constructing the ajax request url,

when change to $data["id"],it works!

In CSqlDataProvider i have set the "keyField" to "id", is it a bug that you always use $data->primaryKey to create the url, in fact $data does have a field call "primaryKey", how can you get the value of it? -- it's just an array of assicative array, which does not have any information about which attribute is the primarykey!

you should have a attribute for us to specify the id attribute name - $idAttr , and use it in initButton method like this : $this->button = array( 'url' => 'Yii::app()->controller->createUrl("' . $this->toggleAction . '",array("pk"=>$data[' . $this->idAttr . '],"attribute"=>"' . $this->name . '"))', 'htmlOptions' => array('class' => $this->name . '_toggle' . $this->uniqueClassSuffix), );

Jay0Wei avatar Nov 30 '16 01:11 Jay0Wei