yii2模版里的匿名函数问题


控制器里没有 $model 变量


 public function actionIndex()
    {
        // if (!ctype_digit($parent)) {
        //     throw new InvalidValueException();
        // }
        $searchModel = new NsortSearch();
        $dataProvider = $searchModel->search(Yii::$app->request->queryParams);

        return $this->render('index', [
            // 'searchModel' => $searchModel,
            'dataProvider' => $dataProvider,
        ]);
    }

但视图中的 $model 是从哪里来的


 [
      'attribute' => 'parent',
      'value' => function ($model) {
                    return empty($model->parent) ? '-' : $model->parent->name;
                },
            ],

yii2 php

平田君加了个油 9 years, 1 month ago

Your Answer