Detach a behavior from a model

I have model A that implements BehaviorX (that extends CActiveRecordBehavior). Model B extends Model A, but I need to detach BehaviorX for that class.

$this->detach doesn’t work.


Model A

class Model_A extends CActiveRecord


  public function behaviors(){

          return array( 

                'BehaviorX' => array(

                 // parameters here




Model B

class Model_B extends Model_A


public functon init() { // this doesn't work


return parent::init();



public function behaviors(){ // this works but... sucks <img src='' class='bbc_emoticon' alt=':)' />

                $arr = parent::behaviors(); //retrieve behaviors array 

                unset($arr['BehaviorX']); // remove item with 'BehaviorX' index from behaviors array

                return ($arr); //returns array without BehaviorX item.



Is there a better ‘Yii way’ to detach a behavior from a model? tia


Something like this shuld work:


or eventually(see that I changed order):

public functon init() { 

$myObj = parent::init();


return myObj;


Sorry, in my code I wrote :


but I tried also with your solution, with no luck:


Also tried with $this->disableBehavior(‘BehaviorX’);

No luck