Here is my _form.php: If I submit this form it is writing 7 items (rows) into database(table ‘task’). i think it is because there are 7 options in dropdownlist (4 projects and 3 employees). So it is writing rows for each options in the dropdownlist. How can i fix it ? Please help me.
<?php $form=$this->beginWidget('bootstrap.widgets.TbActiveForm',array(
'id'=>'task-form',
'enableAjaxValidation'=>true,
)); ?>
<p class="help-block">Fields with <span class="required">*</span> are required.</p>
<?php echo $form->errorSummary($model); ?>
<?php echo $form->textFieldRow($model,'TaskName',array('class'=>'span5','maxlength'=>255)); ?>
<?php echo $form->dropDownListRow($model,'ProjectId',CHtml::listData(Project::model()->findAll(), 'id', 'ShortName')); ?>
<?php echo $form->textFieldRow($model,'Priority',array('class'=>'span5','maxlength'=>45)); ?>
<?php echo $form->datepickerRow($model,'StartDate',array('class'=>'span3')); ?>
<?php echo $form->datepickerRow($model,'EndDate',array('class'=>'span3')); ?>
<?php echo $form->textFieldRow($model,'Budget',array('class'=>'span5')); ?>
<?php echo $form->textAreaRow($model,'Desc',array('rows'=>6, 'cols'=>50, 'class'=>'span6')); ?>
<?php echo $form->textFieldRow($model,'Progress',array('class'=>'span5')); ?>
<?php echo $form->dropDownListRow($model,'idEmployee',CHtml::listData(Employee::model()->findAll(), 'id', 'FirstName')); ?>
<?php echo $form->dropDownListRow($model,'status',array('active'=>'active', 'deleted'=>'deleted'), array('class'=>'span3','maxlength'=>45)); ?>
<div class="form-actions">
<?php $this->widget('bootstrap.widgets.TbButton', array(
'buttonType'=>'submit',
'type'=>'primary',
'label'=>$model->isNewRecord ? 'Create' : 'Save',
)); ?>
</div>
<?php $this->endWidget(); ?>