Yii2 Confirm Widget (e.g. SMS) For example,
'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()]);
}
Comments