PHP code example of sem-soft / yii2-ajax-confirm

1. Go to this page and download the library: Download sem-soft/yii2-ajax-confirm 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/ */

    

sem-soft / yii2-ajax-confirm example snippets


     $form = ActiveForm::begin([
        'id' => 'report_import_form',
        'options' => [
            'enctype' => 'multipart/form-data'
        ],
        'enableAjaxValidation' => false,
    ]); 

  ...
  public function actionExists()
 {
     Yii::$app->response->format = Response::FORMAT_JSON;

     ...

     $form = new FinanceReportImportForm();

     ...

     if ($existReport = FinanceReport::findOne([
         'field1' => $form->field1,
         'field2' => $form->field2
     ])) {
         $question = "Отчет по {$existReport->field1} кварталу {$existReport->field2} отчетного года уже существует и будет перезаписан. Продолжить импорт?";
     } else {
         $question = "Выполнить импорт?";
     }

     ...

     return [
         'can' => $existReport ? false : true,
         'question' => $question
     ];
 }
...