Using Temporary Container To Take User Input


I am working on an implementation where i render some active records (models) and allow user to choose one of them

i have multiple sets where each contains multiple choices

e.g each set has more that one options/choices to chose from.

So to take input from user, i decided to use radiobuttonList() for each set (rendering all options)

Here is what i am doing…

$cntSets = count($sets);

for($setIndex =0; $setIndex<$cntSets;$setIndex++)


&#036;count = count(choices);

&#036;choices = &#036;sets[&#036;setIndex]['choices'];

foreach(&#036;choices &#036;i=&gt;&#036;item)


&#036;option = array();

   for(&#036;i = 0; &#036;i &lt; &#036;count;&#036;i++)


       &#036;option[&#036;ind] = &#036;choices[&#036;i]['label'];


   echo &#036;form-&gt;radioButtonList(&#036;item, &quot;[&#036;i]attributeOfChoice&quot;,





but i want user to choose only one of them which user can. but i not able to figure out a way to know which option was choosen.

is there any way to store id of each "choice" choosen out of every set.

One alternate solution i could think of is, replacing $item with $set and create an attribute in $set to take this input.

i just need a clue how to actually save the id of "choice" i.e. $choices[i].id…!

Pls suggest…!

-Big O

I didn’t get what are you trying to do< I can just give you some general advices:

If you have to collect some input that will not be saved on database, you can use CFormModel.

This class gives you all advantages of CActiveRecord (validation, massive assignament, attributeLabel), and allows you to work with this input in the same way of ActiveRecord.

Hope it helps

If im in right you have multipile models one is $sets an second one is $choices ,

hire is what you have to do

fist you have to set your data as array;

for more information see this link Chtml::listdata

tested and work like a charm :)

$sets = CHtml::listData($sets,'nameofIDproperty','nameofValueproperty');

//you dont nead sets;


//and now thy will be returnet as array()

//like array('1'=>'one','2'=>'two')

// now you have to make tags

$setone = array(59,58,60,70,80,81,82,83); //ids of choices

$settwo = array(1,2,3,11,12,15,16,17); //ids of choices

foreach($setone as $id=>$v){


$dataone['label'] = $choices[$v];

$dataone['value'] =  $choices[$v];



echo CHtml::radioButtonList('setone','1', $dataone);

foreach($settwo as $id=>$v){


$datatwo['label'] = $choices[$v];

$datatwo['value'] =  $choices[$v];



echo CHtml::radioButtonList('settwo','1', $datatwo);