A
A
AlexAll2021-10-14 22:31:19
PHP
AlexAll, 2021-10-14 22:31:19

How to pass value to widget on click to open modal window in yii2?

When I click on the block, I have a widget that opens a modal window. It is necessary that when opening a modal window, the widget receives data from the database by id and user_id (well, this is understandable) and transfers them to the widget's view. How to pass id to widget on click?
Here is the widget code

class GetWebSiteCodeWidget extends Widget


    public function init()
    {
        parent::init();
    }

    public function run()
    {
        if (!Yii::$app->user->isGuest) {
            $userId = Yii::$app->user->identity->getId();
            $hash = Site::find()->select(['hash'])->where(['id' => 8, 'userId' => $userId ])->scalar();

            return $this->render('website-code', [
                'hash' => $hash,
            ]);
        }
    }
}


In the view, I display the widget as usual <?= GetWebSiteCodeWidget::widget()?>

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question