Browse Source

Form create fix

master
Egorka 6 years ago
parent
commit
a9f2361e9c
  1. 3
      common/modules/forms/controllers/manage/FormController.php
  2. 6
      common/modules/forms/forms/FormForm.php
  3. 12
      common/modules/forms/views/manage/form/_form/_form-builder.php
  4. 14
      common/modules/forms/views/manage/form/view.php

3
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\forms\entities\Form;
use common\modules\pages\entities\Page; use common\modules\pages\entities\Page;
use common\modules\forms\forms\FormForm; use common\modules\forms\forms\FormForm;
use yii\helpers\Json;
use yii\web\NotFoundHttpException; use yii\web\NotFoundHttpException;
use yii\filters\AccessControl; use yii\filters\AccessControl;
use yii\filters\VerbFilter; use yii\filters\VerbFilter;
@ -91,6 +92,7 @@ class FormController extends Controller
Yii::$app->session->setFlash('error', $e->getMessage()); Yii::$app->session->setFlash('error', $e->getMessage());
} }
} }
return $this->render('create', [ return $this->render('create', [
'model' => $form, 'model' => $form,
]); ]);
@ -116,6 +118,7 @@ class FormController extends Controller
Yii::$app->session->setFlash('error', $e->getMessage()); Yii::$app->session->setFlash('error', $e->getMessage());
} }
} }
return $this->render('update', [ return $this->render('update', [
'model' => $form, 'model' => $form,
'form_model' => $form_model, 'form_model' => $form_model,

6
common/modules/forms/forms/FormForm.php

@ -3,9 +3,9 @@
namespace common\modules\forms\forms; namespace common\modules\forms\forms;
use common\modules\forms\entities\Form; use common\modules\forms\entities\Form;
use core\validators\SlugValidator;
use yii\base\Model; use yii\base\Model;
use Yii; use Yii;
use yii\helpers\Json;
class FormForm extends Model class FormForm extends Model
{ {
@ -38,6 +38,10 @@ class FormForm extends Model
$this->_form = $form; $this->_form = $form;
} }
else {
$this->data = Json::encode([]);
$this->status = Form::STATUS_ACTIVE;
}
parent::__construct($config); parent::__construct($config);
} }

12
common/modules/forms/views/manage/form/_form/_form-builder.php

@ -29,13 +29,21 @@ $js = <<<JS
}, },
showActionButtons: false, showActionButtons: false,
formData: {$data}, formData: {$data},
fields: [{ fields: [
{
label: 'E-mail', label: 'E-mail',
type: 'text', type: 'text',
subtype: "email", subtype: "email",
placeholder: 'name@email.com', placeholder: 'name@email.com',
icon: '✉' icon: '✉'
}] },
{
label: 'Кнопка отправки',
type: 'button',
subtype: "submit",
icon: '▶'
}
]
}; };
var editor = document.getElementById('fb-editor'); var editor = document.getElementById('fb-editor');

14
common/modules/forms/views/manage/form/view.php

@ -2,9 +2,11 @@
use yii\helpers\Html; use yii\helpers\Html;
use yii\widgets\DetailView; use yii\widgets\DetailView;
use common\modules\forms\entities\Form;
use common\modules\forms\helpers\FormHelper;
/* @var $this yii\web\View */ /* @var $this yii\web\View */
/* @var $form \common\modules\forms\entities\Form */ /* @var $form Form */
$this->title = $form->name; $this->title = $form->name;
$this->params['breadcrumbs'][] = ['label' => Yii::t('form', 'Forms'), 'url' => ['index']]; $this->params['breadcrumbs'][] = ['label' => Yii::t('form', 'Forms'), 'url' => ['index']];
@ -39,7 +41,13 @@ $this->params['breadcrumbs'][] = $this->title;
'from', 'from',
'reply', 'reply',
'return', 'return',
'status', [
'attribute' => 'status',
'format' => 'raw',
'value' => function(Form $form) {
return FormHelper::statusLabel($form->status);
}
],
'captcha', 'captcha',
'complete_page_id' 'complete_page_id'
], ],
@ -48,7 +56,7 @@ $this->params['breadcrumbs'][] = $this->title;
</div> </div>
<div class="box"> <div class="box">
<div class="box-header with-border"><?= Yii::t('page', 'Complete Message') ?></div> <div class="box-header with-border"><?= Yii::t('form', 'Complete Message') ?></div>
<div class="box-body"> <div class="box-body">
<?= Yii::$app->formatter->asHtml($form->complete_text, [ <?= Yii::$app->formatter->asHtml($form->complete_text, [
'Attr.AllowedRel' => array('nofollow'), 'Attr.AllowedRel' => array('nofollow'),

Loading…
Cancel
Save