I create a widget , but I need to pass a parameter to this widget. I need to give channel_id of channel already created to $chn that I use in my widget
my widget is :
<?php
namespace app\components\content\create;
use Yii;
use yii\base\Widget;
use yii\helpers\Html;
use app\models\PostGallery;
use app\models\Permission;
use app\accions\content\AxPostGallery;
class UploadGalleryWidget extends \yii\base\Widget {
public function run() {
$model = new PostGallery; $permission = new Permission; $acc_PGallery = new AxPostGallery;
if ($model->load(Yii::$app->request->post()) )
{
$acc_PGallery->CreateGallery($model, $chn);
}
return $this->render('/postgallery/_formUploadGallery', [
'model' => $model,
'permission' => $permission,
]);
}
}
?>
My view of form is :
<?php $form = ActiveForm::begin(['options' => ['enctype' => 'multipart/form-data']]) ?>
<?= $form->field($model_PstGlr, 'PGalleryFile[]')->fileInput(['multiple' => true, 'accept' => 'image/*']) ?>
<?= $form->field($model_PstGlr, 'post_text')->textarea(['rows' => 2]) ?>
<?= $form->field($model_PstGlr, 'permission_id')->dropdownList($model_Permission->PermissionOn()) ?>
<div class="form-group">
<?= Html::submitButton('Save', ['class' => 'btn btn-success']) ?>
</div>
<?php ActiveForm::end(); ?>
And inside my view of channel I use :
<?= UploadGalleryWidget::widget() ?>
I need to give channel_id of channel already created to $chn that I use in my widget