Keep the activebox status when reloading a page

hi everyone,

In one of my views i have a GridView which displays some textfields and checkboxes.

The problem is that when i select a checkbox,enter some datas in the textfields and submit the page, the checkbox is not checked anymore, but the text that i entered in the text fields are displayed. There’s is a way in the CgridView to keep the state of the checkbox after

reloading the page (displaying error message before saving data to database), as is the case for the textfield ?

Here’s my code:

$this->widget('zii.widgets.grid.CGridView', array( 








	        'htmlOptions'=>array('width'=><img src='' class='bbc_emoticon' alt='8)' />, 



            'name'  => 'id', 

            'htmlOptions' => array('style'=>'width:30px;'), 




            'value'=> '$data->author',             



)); ?>

Thanks for helping :)

As I understand, you use form and GridView to select some items from it to be submited too. May be the better way is to use a simple list of checkboxes?

It’s the same thing. A simple list of checkboxes is generated with the GridView.

What i want is when a user select some checkboxs and submit the form, the rendered page should

keep the checkboxs with the same state than before reloading page. Like with the text fields


Using the list of checkboxes you can pass to CHtml::checkBoxList array of values which should be checked. And this array you can get in controller after submitting the form and than pass it to view.

Simple example


in view file:[/b]

echo CHtml::beginForm();

echo CHtml::checkBoxList('userId', $userId, CHtml::listData(User::model()->findAll(), 'id', 'login'));

... other form fields ...

echo Chtml::submitButton('Post');

echo CHtml::endForm();

in controller’s action:

$userId = array();

if(isset($_POST['userId']) && is_array($_POST['userId']))


  $userId = $_POST['userId'];


$this->render('index', array(

  'userId' => $userId,


That’s exactly what i needed…Thanks a lot