我的视图文件上有 3 个选项卡
第一个标签: 学生
第二个标签:教育
第三个标签:就业
我的表结构:
学生表:
+-------------+------------+--------------+------------+-------------+
| id(PK) | lead_id | st_name | st_email | st_phone |
+-------------+------------+--------------+------------+-------------+
线索详情:
+-------------+-------------+
| id(PK) | lead_ref_id |
+-------------+-------------+
教育
+-------------+------------+--------------+--------------+
| id(PK) | lead_id |education_type|education_year|
+-------------+------------+--------------+--------------+
就业:
+-------------+------------+---------------+---------------------+
| id(PK) | lead_id |Employment_type|Employment_experience|
+-------------+------------+---------------+---------------------+
当我去更新动作时,我必须根据lead_id显示数据
我的学生查看文件代码:
<div class="form">
<?php $form=$this->beginWidget('CActiveForm', array(
'id'=>'lead-student-detail-form',
// Please note: When you enable ajax validation, make sure the corresponding
// controller action is handling ajax validation correctly.
// See class documentation of CActiveForm for details on this.
'enableAjaxValidation'=>false,
'htmlOptions' => array('enctype' => 'multipart/form-data'),
)); ?>
<p class="note">Fields with <span class="required">*</span> are required.</p>
<div class="row">
<?php echo $form->labelEx($model,'st_name'); ?>
<?php echo $form->textField($model,'st_name',array('size'=>50,'maxlength'=>50)); ?>
<?php echo $form->error($model,'st_name'); ?>
</div>
<div class="row">
<?php echo $form->labelEx($model,'st_email'); ?>
<?php echo $form->textField($model,'st_email',array('size'=>50,'maxlength'=>50)); ?>
<?php echo $form->error($model,'st_email'); ?>
</div>
<div class="row">
<?php echo $form->labelEx($model,'st_phone'); ?>
<?php echo $form->textField($model,'st_phone'); ?>
<?php echo $form->error($model,'st_phone'); ?>
</div>
</div><!-- form -->
我的教育视图代码
<div class="form">
<?php $form=$this->beginWidget('CActiveForm', array(
'id'=>'lead-target-education-form',
// Please note: When you enable ajax validation, make sure the corresponding
// controller action is handling ajax validation correctly.
// There is a call to performAjaxValidation() commented in generated controller code.
// See class documentation of CActiveForm for details on this.
'enableAjaxValidation'=>false,
)); ?>
<p class="note">Fields with <span class="required">*</span> are required.</p>
<?php echo $form->errorSummary(array($target)); ?>
</div>
<?php echo $form->labelEx($target,'education_type'); ?>
<?php echo $form->textField($target,'education_type'); ?>
<?php echo $form->error($target,'education_type'); ?>
</div>
</div>
<?php echo $form->labelEx($target,'academic_year'); ?>
<?php echo $form->textField($target,'academic_year[]'); ?>
<?php echo $form->error($target,'academic_year'); ?>
</div>
我应该如何编写动作更新代码,以便数据根据 而lead_id
不是主键显示id
并根据lead_id
.
从评论更新
铅和教育表之间存在一对多的关系。
+-------------+------------+--------------+--------------+
| id(PK) | lead_id |education_type|education_year|
+-------------+------------+--------------+--------------+
| 1 | 1 | 10 | 2003 |
+-------------+------------+--------------+--------------+
| 2 | 1 | 12 | 2005 |
+-------------+------------+--------------+--------------+