Answer the question
In order to leave comments, you need to log in
Why isn't the behavior method called?
here is the behavior
<?php
namespace common\components\behaviors;
use yii\base\Behavior;
class MenuFrontendBehavior extends Behavior
{
public $alias;
public $model;
public $path;
public $feild_alias;
public function getPath(){
return 'yes';
}
public function getModel(){
$model=$this->model;
}
}
use common\components\behaviors\MenuFrontendBehavior;
class Firmcat extends \yii\db\ActiveRecord
{
public function behaviors()
{
return [
[
'class' => SluggableBehavior::className(),
'attribute' => 'title',
'slugAttribute' => 'slug'
],
'menu' => [
'class' => MenuFrontendBehavior::className(),
//'model' => 'yes',
//'prop2' => 'value2',* /
]
];
}
use common\models\Firmcat;
use yii\web\Controller;
class MenucreateController extends Controller
{
public function actionIndex(){
$model=Firmcat::find()->with('image')->all();
return $this->render('index',[
'path'=>$model->getPath()
]);
}
}
Call to a member function getPath() on array
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question