[Solved] Attribute changing during the validation process

I have a really simple part of code acting in a really strange way: In a controller where i’am performing an update i have:




$model->attributes = $_POST['Critique'];

echo $model->id_user;// My new id_user (eg: 5)

 $success = true;

 if(!$model->validate()){

         $success = false;

  }

 echo $model->id_user;// The old id_user (eg: 1)



So as you can see the $model->validate() is changing the value of id_user, setting back the old value even if I have no error during the validation process.

I really don’t understand why!

do you have any custom code in the different onValidate events

I don’t think I have any custom code in those event, but it seems to be onBeforeValidate() that changes the value, I don’t know why!

Just found what is causing trouble: this is EActiveRecordRelationBehavior’s extension!

When i’m deactivating this extension everything is working fine!

yep it must’ve been some custom code.

Yeap, thanks a lot bettor, you really pointed the good direction !!