Skip to content

TbToggleColumn $data->primaryKey is not working #1042

@Jay0Wei

Description

@Jay0Wei

$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), );

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions