CListView inside a CActiveForm

I want to create a quiz with pagination. Therefore, I have the following structure:


<?php $form=$this->beginWidget('CActiveForm', array(

	'id'=>'quiz-form',

	'enableClientValidation'=>false,

	'clientOptions'=>array(

		'validateOnSubmit'=>true,

	),

)); ?>

				<?php $this->widget('zii.widgets.CListView', array(

					'ajaxUpdate'=>false,

					'dataProvider'=>$dataProvider,

					'itemView'=>'_view',

					'template'=>"{items}\n{pager}",

				)); ?>

<?php $this->endWidget(); ?>

Look at the image and you will understand better the situation:

6286

screenshot1.jpg

The problem is, when I click on a page number, the answers are not sent. I tried with the following jQuery but it’s not working:


			$('.page').click(function(){

				$('#quiz-form').submit();

			});

Any ideas?

Perhaps:


$('.page a').click(function(){

	$('#quiz-form').submit();

});

this doesn’t work. In fact, the following “alert” works:


                        $('.page').click(function(){

                                     alert('hello');

                                     $('#quiz-form').submit();

                        });

It would help to know what is actually being send. Without that info an educated guess might be to try:


$('.page').click(function(){

      $('#quiz-form').submit();

      return false;

});

it worked!

Now I have another problem. In the controller, I collect the POST data like this:


		$this->paramKeys = array_keys($_POST);

		$this->paramValues = array_values($_POST);

		$i = 0;

		foreach($this->paramKeys as $paramKey)

		{

			Yii::app()->session[$paramKey] = $this->paramValues[$i];

			$i++;

		}

If I set some answers and I click the same page number, the answers are set (this is correct). However, if I set some answers, click another page number and return back to the previous page, the answers are not set! Maybe this problem is related to sessions, since the variables of the session seem to disappear. I tried with $_SESSION but it happens the same.

You will have to take a look at your _view.php view and probably have to rewrite it to take the session parameters when set.

I already take the session parameters at my _view.php. Look:




<div style="border:1px solid black;margin:10px;padding:10px;">

	<?php

		echo CHtml::encode($data->title);

	?>

	<br/>

	<?php

		echo CHtml::radioButtonList($data->id, Yii::app()->session[$data->id], array(0 => 'false', 1 => 'true'));

	?>

</div>

Finally I solved the problem creating a temporary table. But does anyone know why I can’t use sessions?