From a9f2361e9cd590bbbe170383dc56ade7324e50c6 Mon Sep 17 00:00:00 2001 From: Egorka Date: Wed, 8 Aug 2018 12:43:19 +0300 Subject: [PATCH] Form create fix --- .../forms/controllers/manage/FormController.php | 3 +++ common/modules/forms/forms/FormForm.php | 6 +++++- .../views/manage/form/_form/_form-builder.php | 22 +++++++++++++++------- common/modules/forms/views/manage/form/view.php | 14 +++++++++++--- 4 files changed, 34 insertions(+), 11 deletions(-) diff --git a/common/modules/forms/controllers/manage/FormController.php b/common/modules/forms/controllers/manage/FormController.php index b181cfc..f9966cc 100644 --- a/common/modules/forms/controllers/manage/FormController.php +++ b/common/modules/forms/controllers/manage/FormController.php @@ -7,6 +7,7 @@ use common\modules\forms\forms\FormSearch; use common\modules\forms\entities\Form; use common\modules\pages\entities\Page; use common\modules\forms\forms\FormForm; +use yii\helpers\Json; use yii\web\NotFoundHttpException; use yii\filters\AccessControl; use yii\filters\VerbFilter; @@ -91,6 +92,7 @@ class FormController extends Controller Yii::$app->session->setFlash('error', $e->getMessage()); } } + return $this->render('create', [ 'model' => $form, ]); @@ -116,6 +118,7 @@ class FormController extends Controller Yii::$app->session->setFlash('error', $e->getMessage()); } } + return $this->render('update', [ 'model' => $form, 'form_model' => $form_model, diff --git a/common/modules/forms/forms/FormForm.php b/common/modules/forms/forms/FormForm.php index 133d388..737e952 100644 --- a/common/modules/forms/forms/FormForm.php +++ b/common/modules/forms/forms/FormForm.php @@ -3,9 +3,9 @@ namespace common\modules\forms\forms; use common\modules\forms\entities\Form; -use core\validators\SlugValidator; use yii\base\Model; use Yii; +use yii\helpers\Json; class FormForm extends Model { @@ -38,6 +38,10 @@ class FormForm extends Model $this->_form = $form; } + else { + $this->data = Json::encode([]); + $this->status = Form::STATUS_ACTIVE; + } parent::__construct($config); } diff --git a/common/modules/forms/views/manage/form/_form/_form-builder.php b/common/modules/forms/views/manage/form/_form/_form-builder.php index 6612210..bb6ee49 100644 --- a/common/modules/forms/views/manage/form/_form/_form-builder.php +++ b/common/modules/forms/views/manage/form/_form/_form-builder.php @@ -29,13 +29,21 @@ $js = <<title = $form->name; $this->params['breadcrumbs'][] = ['label' => Yii::t('form', 'Forms'), 'url' => ['index']]; @@ -39,7 +41,13 @@ $this->params['breadcrumbs'][] = $this->title; 'from', 'reply', 'return', - 'status', + [ + 'attribute' => 'status', + 'format' => 'raw', + 'value' => function(Form $form) { + return FormHelper::statusLabel($form->status); + } + ], 'captcha', 'complete_page_id' ], @@ -48,7 +56,7 @@ $this->params['breadcrumbs'][] = $this->title;
-
+
formatter->asHtml($form->complete_text, [ 'Attr.AllowedRel' => array('nofollow'),