MichaelP
(Michael Pruss)
1
Hey guys,
I’m new to Yii and got a little problem regarding the new ‘checked’ property of CCheckboxcolumn.
I use a CGridView widget and want the checkboxes in the columns where the value of data->id is in an array to be preselected.
So I tried this:
array( 'class'=>'CCheckBoxColumn', 'id'=>'selected_subscribers', 'checked'=>in_array($data->id, $checked_keys).""),
Even though some of the id’s are definetly in the $checked_keys array, all checkboxes are unchecked.
Can you help me?
Cheers
Michael
ortenheim
(M Ortenheim)
2
i am having this problem as well. did you solve this?
j_fiel
(J Fiel)
3
You are almost there. You need to create a string from the entire expression so that CCheckBoxColumn can eval the expression.
The expression:
$checkedExpression = 'in_array($data->id,array('.implode(',', $checked_keys).'))';
Then you can add your column:
array( 'class'=>'CCheckBoxColumn', 'id'=>'selected_subscribers', 'checked'=>$checkedExpression),