I Need Example And Full Document For Cmodel->Behaviors() Method.

I need example and full document for CModel->behaviors() method. Can anyone help me?

behaviors are used to attach other classes into your classes so that you can use the methods of another classes into your class without any problem. say you have two classes one is ClassA it extends from CActiveRecord and ClassB extends from CBehavior or its child classes,( ClassB has one method MethodC when ClassB is attached to ClassA you can use the method MethodB in ClassA as like the normal method. for more info refer guide about behaviors

to attach ClassB use like this




//here I assumed that your behavior is inside components folder

//now you are ready to use this

public function behaviors()

{

 return array(

    'some-name'=>array(

            'class'=>'ClassB'

    )

);

}







/**

 * behaviors definitions method

 * @return array

 */

public function behaviors()

{

    $parents_b = parent::behaviors();

    $new_b = array(

        'slugmaker' => array(

            'class' => 'PcSimpleSlugBehavior',

            // going with default configuration for this slug behavior

        ),

        'limitEditTimePeriod' => array(

            'class' => 'PcLimitEditTimePeriod',

            'timeout' => self::EDIT_TIME_LIMIT,

        ),

    );

    return array_merge($parents_b, $new_<img src='http://www.yiiframework.com/forum/public/style_emoticons/default/cool.gif' class='bbc_emoticon' alt='B)' />;

}



Thank you very very much Ahamed Rifaideen and Boaz :). your help is very useful. Thank you again my friends.