[SOLVED] activeRadioButtonList

I currently have a radio button list with a template but I would like to display an additional attribute other than the button and the value.

My code:




<div class="row">

	<?php echo $form->labelEx($model,'recordId'); ?>

	<?php

		echo '<table><tr>';

		echo CHtml::activeRadioButtonList($model,'recordId',

			CHtml::listData(Record::model()->findAll(), 'id', 'name'),

			array(

				'separator'=>'', 

				'template'=>'<td><table><tr><td>{label}</td></tr><tr><td>{input}</td></tr></table></td>',

				'labelOptions'=>array('style'=>'display:inline')

			));

		echo '</tr></table>';

	?>

	<?php echo $form->error($model,'recordId'); ?>

</div>



How do I access the data returned by the listData to add another row into the template and display a value?




<div class="row">

	<?php echo $form->labelEx($model,'recordId'); ?>

	<?php

		echo '<table><tr>';

		echo CHtml::activeRadioButtonList($model,'recordId',

			CHtml::listData(Record::model()->findAll(), 'id', 'name'),

			array(

				'separator'=>'', 

				'template'=>'<td><table><tr><td>{label}</td></tr><tr><td> record value here</td></tr><tr><td>{input}</td></tr></table></td>',

				'labelOptions'=>array('style'=>'display:inline')

			));

		echo '</tr></table>';

	?>

	<?php echo $form->error($model,'recordId'); ?>

</div>



Would this be done by extending the radio button or the listData or?

Thanks,

You can simpy copy the code of CHtml::listData and change to fit your needs.

You have to create a class KHtml extends CHtml and add your method.

Thanks, I was thinking that I’d have to do that but was hoping there might have been a simpler method.

could you explain this a little more with an example?

I am not quite clear on how you get the data for the individual list items within the template.

Thanks