Trying to create my first behavior:

use backend\modules\menus\behavior\MenuFrontendBehavior; class Firmcat extends \yii\db\ActiveRecord { public function behaviors() { return [ [ [ 'class' => SluggableBehavior::className(), 'attribute' => 'title', 'slugAttribute' => 'slug' ], 'MenuFrontendBehavior' => [ 'class' => MenuFrontendBehavior::className(), ] ] ]; } 

So trying to get it in the module controller:

 class Firmcat extends \yii\db\ActiveRecord { public function behaviors() { return [ [ [ 'class' => SluggableBehavior::className(), 'attribute' => 'title', 'slugAttribute' => 'slug' ], 'MenuFrontendBehaviors' => [ 'class' => MenuFrontendBehavior::className(), //'model' => 'yes', //'prop2' => 'value2',* / ] ] ]; } 

Gives an error message:

 Invalid Configuration – yii\base\InvalidConfigException Object configuration must be an array containing a "class" element. 

What am I doing wrong?

  • Check how the word "class" is written in you, Russian letters can often get there - Alex Marchenkovsky

1 answer 1

an extra array was added one pair [] was an extra