[Solved] Collect Form Input

Another day struggling with a piece of code and need to get some inputs to proceed.

I have a form that displays the results of a db query ($items) in a tabular manner. I need to have either a radio button or a submit button that will return the value of the row or a unique field from the $items list.

The partial form code is below:

<div class="form">

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






)); ?>


<tr><th>Name</th><th>Match Time</th><th>Clubs Free</th><th>Your Choice</th></tr>

<?php foreach($items as $i=>$item): ?>


<td><?php echo "$item[nameCountry]" ?></td>

<td><?php echo "$item[time]"; ?></td>

<td><?php echo "$item[clubsFree]"; ?></td>


<?php echo CHtml::radioButton("$item[idCountry]"); ?>


 <td><input type="submit" id=<?php echo "$item[idCountry]" ?> name="countrySelected" value="Select"/>



<?php endforeach; ?>


	<div class="row buttons">

		<?php echo CHtml::hiddenField('idCountry',null,array('id'=>'select-form')); ?> 

		<?php echo CHtml::submitButton('Select'); ?>


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

</div><!-- form -->

I have tried a var_dump of the POST array, but I do not get a unique value on either the radio button or the submit button.

why don’t you try $form->radioButton($model,$attribute);

will this ensure that the radio button on each row will have a unique value, tied to the rest of the tabular data?

to ensure they will have unique name predefine their names:

$form->radioButton($model,$attribute, array(‘name’=>‘ModelName[attributename][]’);

that should work

Will try that.

Is there no way to achieve what I want using CHtml::radioButton?

<?php echo CHtml::radioButton("select",'',array('value'=>"$item[idCountry]")); ?>

That solved it for me. :)

Thanks bettor!