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'=>'detail-form',
)); ?>
<p class="note">Fields with <span class="required">*</span> are required.</p>
<?php $student = Student::model()->findAllByAttributes(array(
'teacher_id'=>array('value'=>Yii::app()->user->getId())
));
?>
<?php $teacher = Teacher::model()->findAll();?>
<?php echo $form->errorSummary($model); ?>
<table>
<tr>
<th>
<?php echo $form->labelEx($model,'Nama Guru'); ?>
<?php echo $form->hiddenField($model, 'teacher_id', array('value'=>Yii::app()->user->getId())); ?>
<?php echo $form->textField($model, 'teacher_id', array('value'=>Teacher::model()->findByAttributes(array('id'=>Yii::app()->user->name))->name, 'disabled'=>true)); ?>
<?php echo $form->error($model,'teacher_id'); ?>
</th>
<th>&nbsp;</th>
</tr>
<tr>
<th>
<?php echo $form->labelEx($model,'date'); ?>
<?php echo $form->textField($model,'date'); ?>
<?php echo $form->error($model,'date'); ?>
</th>
<th>&nbsp;</th>
</tr>
<tr>
<td colspan="3"><hr /></td>
</tr>
<tr>
<td>
<?php echo $form->labelEx($model,'Nama Murid'); ?>
</td>
<td>
<?php echo $form->labelEx($model,'status'); ?>
</td>
</tr>
<?php foreach($student as $i=>$stud): ?>
<tr>
<td>
<?php echo $form->hiddenField($model, 'student_id', array('value'=>Student::model()->findByPk($stud->id)->id)); ?>
<?php echo $form->textField($stud,"[$i]name", array('disabled' => true)); ?>
<?php echo $form->error($model,'student_id'); ?>
</td>
<td>
<?php echo $form->dropDownList($model,'status', array('1'=>'Hadir', '2'=>'Tidak Hadir')); ?>
<?php echo $form->error($model,'status'); ?>
</td>
<?php endforeach; ?>
<td>
<?php echo CHtml::submitButton($model->isNewRecord ? 'Simpan' : 'Save'); ?>
</td>
</tr>
</table>
<?php $this->endWidget(); ?>
</div><!-- form -->
SiteController.php
public function actionCreate()
{
$model=new Detail;
if(isset($_POST['Detail']))
{
$model->attributes=$_POST['Detail'];
if($model->save())
$this->redirect(array('index'));
}
$this->render('create',array(
'model'=>$model,
));
}