我是 yii2 的新手...我需要在 yii2 应用程序中使用这个小部件: https ://github.com/2amigos/yii2-file-upload-widget
但是当我安装它时,抛出这个错误: 未定义的变量:模型
有一个画面: http: //prntscr.com/bnvul8
有什么建议吗?
-- controllers/AdminController.php -- (什么时候传递 $model,在这里是未定义的......但是,在 github 页面上,不要使用这个传递。)
public function actionGallery()
{
if (Yii::$app->user->isGuest) {
return $this->redirect('index');
}
$this->layout = 'adminlayout';
return $this->render('gallery', [
'model'=> $model
]);
}
-- 查看/gallery.php --
use dosamigos\fileupload\FileUploadUI;
...
<?= FileUploadUI::widget([
'model' => $model,
'attribute' => 'image',
'url' => ['media/upload', 'id' => $tour_id],
'gallery' => false,
'fieldOptions' => [
'accept' => 'image/*'
],
'clientOptions' => [
'maxFileSize' => 2000000
],
// ...
'clientEvents' => [
'fileuploaddone' => 'function(e, data) {
console.log(e);
console.log(data);
}',
'fileuploadfail' => 'function(e, data) {
console.log(e);
console.log(data);
}',
],