probem with radiobuttonlist html output

Hey,

I’ve some problems with radiobuttonlist html output.

I’m new to yii framework but with a good oo-programming level (come from java).

I want to display a multi-choice quizz but there is a problem with the html output.

the "name" parameter of radio button are the same no matter the considered question.

Actually my radiobuttonlist output the following with the same name parameter (name="Question[id]) everywhere, the quizz is unusable!


<span> Question #1 : Capital of France </span>


<input id="ytQuestion[id]" type="hidden" value="" name="Question[id]" />

<input id="Question[id]_0" value="option1" type="radio" name="Question[id]" /> 

<label for="Question[id]_0">Paris</label><br/>

<input id="Question[id]_1" value="option2" type="radio" name="Question[id]" /> 

<label for="Question[id]_1">London</label>


<span> Question #2 : Capital of Spain</span>


<input id="ytQuestion[id]" type="hidden" value="" name="Question[id]" />

<input id="Question[id]_0" value="option1" type="radio" name="Question[id]" /> 

<label for="Question[id]_0">Barcelona</label><br/>

<input id="Question[id]_1" value="option2" type="radio" name="Question[id]" /> 

<label for="Question[id]_1">Madrid</label>

Can anyone help?

thanks.

eureka

Can you please include the actual view code you are using to produce this…

Here is my view code.


<div class="form"> 

	<?php echo CHtml::beginForm(); ?> 

	<?php echo CHtml::errorSummary($model); ?> 

	<?php 

		foreach($model->_questions as $question){

		

		echo '<div class="row"> ';

	 	echo "<span>Question : $question->question</span>"; 

	 	echo '</div>';

	 	echo'<div class="row">';

		echo CHtml::activeRadioButtonList($question,'id', array(

				'option1'=>$question->option1,

				'option2'=>$question->option2,

			)); 

		echo "</div>"; 

	

	}	

	?>


</div>

$model->_questions is an array of question item object which looks like (see below)

Question{

$question;

$option1;

$option2;

}

I think I find it out! I used ActiveRadioButtonList which links the whole data (radio items) to a unique name $theGivenModel[$theGivenattribute] (through the resolveName function in the CHtml class.

To deal with a more general form, need to use a simple RadioButtonList instead.