public function actions()
 {
     $actions = parent::actions();
     $actions['index']['prepareDataProvider'] = function () {
         // Get id param
         $request = \Yii::$app->getRequest();
         $id = $request->get('id');
         $query = FormRule::find()->where('form_id=:form_id', [':form_id' => $id]);
         return new ActiveDataProvider(['query' => $query]);
     };
     return $actions;
 }
Exemple #2
0
 /**
  * @inheritdoc
  */
 public function beforeDelete()
 {
     if (parent::beforeDelete()) {
         // Delete related Models
         $this->formData->delete();
         $this->ui->delete();
         $this->formConfirmation->delete();
         $this->formEmail->delete();
         // Delete all Charts, Submissions and Files related to this form
         // We use deleteAll for performance reason
         FormUser::deleteAll(["form_id" => $this->id]);
         FormRule::deleteAll(["form_id" => $this->id]);
         FormChart::deleteAll(["form_id" => $this->id]);
         FormSubmissionFile::deleteAll(["form_id" => $this->id]);
         FormSubmission::deleteAll(["form_id" => $this->id]);
         // Delete all Stats related to this form
         Event::deleteAll(["app_id" => $this->id]);
         StatsPerformance::deleteAll(["app_id" => $this->id]);
         StatsSubmissions::deleteAll(["app_id" => $this->id]);
         // Removes files directory (and all its content)
         // of this form (if exists)
         FileHelper::removeDirectory($this::FILES_DIRECTORY . DIRECTORY_SEPARATOR . $this->id);
         return true;
     } else {
         return false;
     }
 }