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. 22
      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\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,

6
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);
}

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

@ -29,13 +29,21 @@ $js = <<<JS
},
showActionButtons: false,
formData: {$data},
fields: [{
label: 'E-mail',
type: 'text',
subtype: "email",
placeholder: 'name@email.com',
icon: '✉'
}]
fields: [
{
label: 'E-mail',
type: 'text',
subtype: "email",
placeholder: 'name@email.com',
icon: '✉'
},
{
label: 'Кнопка отправки',
type: 'button',
subtype: "submit",
icon: '▶'
}
]
};
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\widgets\DetailView;
use common\modules\forms\entities\Form;
use common\modules\forms\helpers\FormHelper;
/* @var $this yii\web\View */
/* @var $form \common\modules\forms\entities\Form */
/* @var $form Form */
$this->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;
</div>
<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">
<?= Yii::$app->formatter->asHtml($form->complete_text, [
'Attr.AllowedRel' => array('nofollow'),

Loading…
Cancel
Save