lets consider two tables Employee and Department, Employee column field Department-id refers to Department etc.. and you want to display a dropdrop rather than textfield in the create view.
protected/views/Department/_form.php
beginWidget('CActiveForm', array(
'id'=>'employee-form',
'enableAjaxValidation'=>false,
)); ?>
Fields with * are required.
errorSummary($model); ?>
labelEx($model,'departmentId'); ?>
textField($model,'departmentId'); ?>
dropDownList($model,'departmentId', CHtml::listData(TestDepartment::model()->findAll(), 'id', 'departmentName')); ?>
error($model,'departmentId'); ?>
labelEx($model,'firstName'); ?>
textField($model,'firstName',array('size'=>20,'maxlength'=>20)); ?>
error($model,'firstName'); ?>
labelEx($model,'lastName'); ?>
textField($model,'lastName',array('size'=>40,'maxlength'=>40)); ?>
error($model,'lastName'); ?>
labelEx($model,'email'); ?>
textField($model,'email',array('size'=>60,'maxlength'=>60)); ?>
error($model,'email'); ?>
labelEx($model,'ext'); ?>
textField($model,'ext'); ?>
error($model,'ext'); ?>
labelEx($model,'hireDate'); ?>
textField($model,'hireDate'); ?>
error($model,'hireDate'); ?>
labelEx($model,'leaveDate'); ?>
textField($model,'leaveDate'); ?>
error($model,'leaveDate'); ?>
endWidget(); ?>
No comments:
Post a Comment