Hi there,
I have two problems extending CButtonColumn and would appreciate any help as I found no solution in documentation. I’ve separated both problems into two topic as they are quite different and one post holding both of them become to long - no one would like to read it! :] Second problem has been described in this post.
[b]
[/b]I want to make delete button in CGridView behave exactly as delete menu item on view / update views generated by Gii for CRUD. But how to achieve this?
It is written in documentation that: “In the PHP expression for the ‘url’ option and/or ‘visible’ option, the variable $row refers to the current row number (zero-based), and $data refers to the data model for the row”. Why the same isn’t available for any other CButtonColumn property? For me, the easiest way would be to use code:
array
(
'class'=>'CButtonColumn',
'deleteConfirmation'=>'Do you really want to delete element with ID = !'.$data->ID."?"
),
Unfortunately this fails with "Undefined variable: data".
Then I tried:
'class'=>'CButtonColumn',
'template'=>'{delete}',
'buttons'=>array
(
'delete' => array
(
'label'=>'[-]',
'url'=>'"#"',
'linkOptions'=>array
(
'submit'=>array('delete', 'id'=>1),
'confirm'=>'Delete?'
)
)
),
But this also is not working - default confirmation is show, probably because linkOptions is not an element of button configuration array!
And, again, if I change 1 at the end of submit to:
'submit'=>array('delete', 'id'=>$data->ID),
'confirm'=>'Delete element ID = '.$data->ID.'?'
I got the same error, saying "Undefined variable: data".
I’m running out of ideas!