If any field of the form is unchanged then set flag to 1, and if any field of the form is changed then set flag to 0. Below is view:
<div class="row">
<?php echo $form->labelEx($model,'name'); ?>
<?php echo $form->textField($model,'name'); ?>
<?php echo $form->error($model,'name'); ?>
</div>
<div class="row">
<?php echo $form->labelEx($model,'email'); ?>
<?php echo $form->textField($model,'email'); ?>
<?php echo $form->error($model,'email'); ?>
</div>
If you are using Y1.1
You can do this in the model, by creating two functions function named beforeSave() and afterFind. Yii will automatically call this before saving the record, and after finding the record.
Your strategy is to make a copy of the record when you find it, and before you update it, check the current values (from the form) with the previous values.
class User extends CActiveRecord
{
public $oldRecord;
public function afterFind()
{
$this->oldRecord=clone $this;
return parent::afterFind();
}
public function beforeSave()
{
if ($this->oldRecord->email !== $this->email) {
$this->changed_record_flag = true;
}
}
}