PHP code example of icron / yii2-confirm-widget

1. Go to this page and download the library: Download icron/yii2-confirm-widget library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

icron / yii2-confirm-widget example snippets


'components' => [
        'confirm' => [
            'class' => 'icron\confirm\Confirm',
            'provider' => 'app\components\providers\ProstorSMS',
        ],
 ],

\icron\confirm\ConfirmWidget::widget([
            'model' => (new \app\models\TestModel()),
            'attribute' => 'phone',
            'clientOptions' => [
                'url' => \yii\helpers\Url::toRoute('site/confirm'),
                'btnSend' => '.btn-send',
                'btnConfirm' => '.btn-confirm',
                'inputCode' => '.input-code'
            ],
            'clientEvents' => [
                'send.ic.modal' => 'function(e){
                    console.log(e.confirmData);
                }',
                'confirm.ic.modal' => 'function(e){
                    var data = e.confirmData || {};
                    console.log(e.confirmData);
                    if (data["status"] == "success") {
                        document.location.href = "' . \yii\helpers\Url::toRoute('site/private') . '";
                    }

                }',
            ],
        ]); 

    public function actionPrivate()
    {
        /** @var Confirm $confirm */
        $confirm = Yii::$app->confirm;
        return $this->render('private', ['items' => $confirm->getConfirmedDestinations()]);
    }