I'm new in yii2... I need to use this widget in yii2 app: https://github.com/2amigos/yii2-file-upload-widget
But when I install it, throw this error: Undefined variable: model
There is a screen: http://prntscr.com/bnvul8
Any suggession?
-- controllers/AdminController.php -- (when is pass the $model, is undefined in here... but, on the github page, don't use this pass.)
public function actionGallery()
{
if (Yii::$app->user->isGuest) {
return $this->redirect('index');
}
$this->layout = 'adminlayout';
return $this->render('gallery', [
'model'=> $model
]);
}
-- view/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);
}',
],