我有一个包含有关用户信息的所有字段的模型。并使用 crud 生成器创建视图并修改视图、表单视图,如下所示
在这里,我隐藏了编辑配置文件部分,当用户单击编辑时,它会显示弹出窗口和编辑字段选项。现在的问题是,当我提交时它会提交整个表单,但我只需要提交已编辑的部分,还有一个问题是,当我编辑某些内容然后取消表单时,它仍然保持编辑的值并保存,然后当我提交任何表格的其他部分。请建议我如何实现表单的部分提交
<?php $form=$this->beginWidget('CActiveForm', array(
'id'=>'my-form',
'enableAjaxValidation'=>true,
'htmlOptions'=>array('enctype'=>'multipart/form-data'),
'action' => Yii::app()->createUrl('/userprofile/editprofile&id='.$model->id),
));
?>
<h4>Edit Profile Pic</h4>
<div>
<?php echo CHtml::fileField('profilePic'); ?>
<div id="editpic"></div>
<div class="btns" id="uploadbutton">
<?php echo CHtml::ajaxSubmitButton('Update', $this->createUrl('/rageprofile/editprofile&id='.$model->id), array('update'=>'#targetdiv'));?>
</div>
</div>
<div class="editbutton">✎ Edit</div>
<div class="eitit edly einfo" style="z-index:9001;" >
<span class="close">✖</span>
<h4>Basic Info</h4>
<?php echo $form->labelEx($model,'firstName'); ?>
<?php echo $form->textField($model,'firstName',array('size'=>30,'maxlength'=>30)); ?>
<?php echo $form->error($model,'firstName'); ?>
<?php echo $form->labelEx($model,'middleName'); ?>
<?php echo $form->textField($model,'middleName',array('size'=>30,'maxlength'=>30)); ?>
<?php echo $form->error($model,'middleName'); ?>
<?php echo $form->labelEx($model,'lastName'); ?>
<?php echo $form->textField($model,'lastName',array('size'=>30,'maxlength'=>30)); ?>
<?php echo $form->error($model,'lastName'); ?><br>
<?php echo $form->labelEx($model,'DOB'); ?>
<?php echo $form->textField($model,'d_o_b',array('size'=>30,'maxlength'=>30)); ?>
<?php echo $form->error($model,'d_o_b'); ?><br>
<?php echo $form->textField($model,'m_o_b',array('size'=>30,'maxlength'=>30)); ?>
<?php echo $form->error($model,'m_o_b'); ?><br>
<?php echo $form->textField($model,'y_o_b',array('size'=>30,'maxlength'=>30)); ?>
<?php echo $form->error($model,'y_o_b'); ?><br>
<?php echo $form->labelEx($model,'City'); ?>
<?php echo $form->textField($model,'city',array('size'=>30,'maxlength'=>30)); ?>
<?php echo $form->error($model,'city'); ?><br>
<?php echo $form->labelEx($model,'State'); ?>
<?php echo $form->textField($model,'state',array('size'=>30,'maxlength'=>30)); ?>
<?php echo $form->error($model,'state'); ?><br>
<?php echo $form->labelEx($model,'Country'); ?>
<?php echo $form->textField($model,'country',array('size'=>30,'maxlength'=>30)); ?>
<?php echo $form->error($model,'country'); ?><br>
<?php echo CHtml::ajaxSubmitButton('Update', $this->createUrl('/rageprofile/editprofile&id='.$model->id), array('update'=>'#targetdiv'));?>
</div>
</div>
</div>
<?php $this->endWidget(); ?>