model - Having multiple radiobuttonlist in a form in yii -


i have model named "myform" , each myform has 25 questions(questions themselfs not store in database).answer each question store in table ( table ), there 1 many relations between form , answers. want show each question in form radiobuttonlist , save or retrieve data to/from database. know can show radiobutton this:

<?php echo $form->radiobuttonlist($model,'question', array('1'=>'option1 ', '2'=>'option 2 ', '3'=>'option3 ')); ?> 

and set value this:

$model->question='1'; 

now should show/save other questions? cause second, third questions need question2 ,question3 in second parameter des not exists in model.

if want save 25 answers each model need 25 columns in answers table, each row represents record the 25 answers.

your table should have columns id, name (or other info), answer1, answer2, answer3, , on.

when receive answers should save using

$answermodel->answer1 = $_post['questionform']['question1']; $answermodel->answer2 = $_post['questionform']['question2']; $answermodel->answer3 = $_post['questionform']['question3']; ... on ... 

Comments

Popular posts from this blog

jQuery Mobile app not scrolling in Firefox -

c++ - How to add Crypto++ library to Qt project -

php array slice every 2th rule -