Student Attendance Record System (_form.php)

function actionCreate only save one row of data in database, anyone can help me ?

_form.php

<div class="form">

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

'id'=&gt;'detail-form',

)); ?>

&lt;p class=&quot;note&quot;&gt;Fields with &lt;span class=&quot;required&quot;&gt;*&lt;/span&gt; are required.&lt;/p&gt;





&lt;?php &#036;student = Student::model()-&gt;findAllByAttributes(array(


    'teacher_id'=&gt;array('value'=&gt;Yii::app()-&gt;user-&gt;getId())


));


?&gt;


&lt;?php &#036;teacher = Teacher::model()-&gt;findAll();?&gt;





&lt;?php echo &#036;form-&gt;errorSummary(&#036;model); ?&gt;

<table>

&lt;tr&gt;


 &lt;th&gt;


	&lt;?php echo &#036;form-&gt;labelEx(&#036;model,'Nama Guru'); ?&gt;                                                  


   	&lt;?php echo &#036;form-&gt;hiddenField(&#036;model, 'teacher_id', array('value'=&gt;Yii::app()-&gt;user-&gt;getId())); ?&gt;


    &lt;?php echo &#036;form-&gt;textField(&#036;model, 'teacher_id', array('value'=&gt;Teacher::model()-&gt;findByAttributes(array('id'=&gt;Yii::app()-&gt;user-&gt;name))-&gt;name, 'disabled'=&gt;true)); ?&gt; 


	&lt;?php echo &#036;form-&gt;error(&#036;model,'teacher_id'); ?&gt;





&lt;/th&gt;


&lt;th&gt;&amp;nbsp;&lt;/th&gt;


&lt;/tr&gt;





&lt;tr&gt;


&lt;th&gt;


	&lt;?php echo &#036;form-&gt;labelEx(&#036;model,'date'); ?&gt;


    &lt;?php echo &#036;form-&gt;textField(&#036;model,'date'); ?&gt;


	&lt;?php echo &#036;form-&gt;error(&#036;model,'date'); ?&gt;


    &lt;/th&gt;


    &lt;th&gt;&amp;nbsp;&lt;/th&gt;


&lt;/tr&gt;





&lt;tr&gt;


&lt;td colspan=&quot;3&quot;&gt;&lt;hr /&gt;&lt;/td&gt;


&lt;/tr&gt;





&lt;tr&gt;


   &lt;td&gt;


	&lt;?php echo &#036;form-&gt;labelEx(&#036;model,'Nama Murid'); ?&gt;


   &lt;/td&gt;





   &lt;td&gt;


	&lt;?php echo &#036;form-&gt;labelEx(&#036;model,'status'); ?&gt;


   &lt;/td&gt;


   


   


&lt;/tr&gt;

<?php foreach($student as $i=>$stud): ?>

<tr>

&lt;td&gt;    


&lt;?php echo &#036;form-&gt;hiddenField(&#036;model, 'student_id', array('value'=&gt;Student::model()-&gt;findByPk(&#036;stud-&gt;id)-&gt;id)); ?&gt;


&lt;?php echo &#036;form-&gt;textField(&#036;stud,&quot;[&#036;i]name&quot;, array('disabled' =&gt; true)); ?&gt;


&lt;?php echo &#036;form-&gt;error(&#036;model,'student_id'); ?&gt;


&lt;/td&gt;


    


&lt;td&gt;


&lt;?php echo &#036;form-&gt;dropDownList(&#036;model,'status', array('1'=&gt;'Hadir', '2'=&gt;'Tidak Hadir')); ?&gt;


&lt;?php echo &#036;form-&gt;error(&#036;model,'status'); ?&gt;


&lt;/td&gt;


&lt;?php endforeach; ?&gt;





&lt;td&gt;


&lt;?php echo CHtml::submitButton(&#036;model-&gt;isNewRecord ? 'Simpan' : 'Save'); ?&gt;


&lt;/td&gt;

</tr>

</table>

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

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

SiteController.php

public function actionCreate()

{


    &#036;model=new Detail;





    if(isset(&#036;_POST['Detail']))


    { 


        &#036;model-&gt;attributes=&#036;_POST['Detail'];


        if(&#036;model-&gt;save())


            &#036;this-&gt;redirect(array('index'));


    }





    &#036;this-&gt;render('create',array(


        'model'=&gt;&#036;model,


    ));

}