I have a standard CTimestampBehavior attached to one of my models:
public function behaviors()
{
return array
(
'timestamp' => array
(
'class'=>'zii.behaviors.CTimestampBehavior',
'createAttribute'=>'creation_date',
'updateAttribute'=>'modification_date',
'setUpdateOnCreate'=>TRUE
)
);
}
It works just perfectly and correctly updates dates, each time model is saved.
But, is there any way to block this behavior in certain situations? For example, when I update model via AJAX. I was thinking about making AJAX-update a separate scenario and attach this behavior only to a specific scenarios, thus excluding its execution upon AJAX update. Is this a correct path?
Or maybe I have to drop using default CTimestampBehavior and write own solution – i.e. for example in afterSafe() check if request is via AJAX and if not, then only then update dates?