Commit 780a36c1 by semenov

new module

parent 3edf9a09
...@@ -11,7 +11,6 @@ use skeeks\cms\base\db\ActiveRecord; ...@@ -11,7 +11,6 @@ use skeeks\cms\base\db\ActiveRecord;
use skeeks\cms\models\behaviors\HasDescriptionsBehavior; use skeeks\cms\models\behaviors\HasDescriptionsBehavior;
use skeeks\cms\models\behaviors\HasStatus; use skeeks\cms\models\behaviors\HasStatus;
use skeeks\cms\models\behaviors\Implode; use skeeks\cms\models\behaviors\Implode;
use skeeks\cms\models\behaviors\Serialize;
use skeeks\cms\models\Core; use skeeks\cms\models\Core;
/** /**
...@@ -33,12 +32,7 @@ class Form extends Core ...@@ -33,12 +32,7 @@ class Form extends Core
*/ */
public function behaviors() public function behaviors()
{ {
return array_merge(parent::behaviors(), [ return array_merge(parent::behaviors(), []);
[
"class" => Serialize::className(),
'fields' => ['emails', 'phones', 'elements']
],
]);
} }
/** /**
...@@ -47,12 +41,25 @@ class Form extends Core ...@@ -47,12 +41,25 @@ class Form extends Core
public function rules() public function rules()
{ {
return array_merge(parent::rules(), [ return array_merge(parent::rules(), [
[['created_by', 'updated_by', 'created_at', 'updated_at'], 'integer'],
[['name'], 'required'], [['name'], 'required'],
[['name', 'description'], 'string'], [['description', 'template'], 'string'],
[['emails', 'phones', 'elements'], 'safe'], [['name'], 'string', 'max' => 255],
[['code'], 'string', 'max' => 32],
[['code'], 'unique'],
[['code'], 'validateCode']
]); ]);
} }
public function validateCode($attribute)
{
if(!preg_match('/^[a-z]{1}[a-z0-1-]{3,32}$/', $this->$attribute))
{
$this->addError($attribute, 'Используйте только буквы латинского алфавита и цифры. Начинаться должен с буквы. Пример block1.');
}
}
public function scenarios() public function scenarios()
{ {
$scenarios = parent::scenarios(); $scenarios = parent::scenarios();
...@@ -68,12 +75,13 @@ class Form extends Core ...@@ -68,12 +75,13 @@ class Form extends Core
*/ */
public function attributeLabels() public function attributeLabels()
{ {
return array_merge(parent::attributeLabels(), [ return array_merge(parent::attributeLabels(), [
'id' => \Yii::t('app', 'ID'), 'id' => \Yii::t('app', 'ID'),
'name' => \Yii::t('app', 'Name'), 'name' => \Yii::t('app', 'Name'),
'description' => \Yii::t('app', 'Description'), 'code' => \Yii::t('app', 'Уникальный код'),
'description' => \Yii::t('app', 'Небольшое описание'),
'template' => \Yii::t('app', 'Шаблон формы'),
]); ]);
} }
} }
\ No newline at end of file
<?php <?php
/** /**
* LoginForm
*
* @author Semenov Alexander <semenov@skeeks.com> * @author Semenov Alexander <semenov@skeeks.com>
* @link http://skeeks.com/ * @link http://skeeks.com/
* @copyright 2010-2014 SkeekS (Sx) * @copyright 2010 SkeekS (СкикС)
* @date 28.10.2014 * @date 07.03.2015
* @since 1.0.0
*/ */
namespace skeeks\modules\cms\form\models; namespace skeeks\modules\cms\form\models;
use Yii; use skeeks\cms\base\db\ActiveRecord;
use yii\base\Model; use skeeks\cms\models\behaviors\HasDescriptionsBehavior;
use skeeks\cms\models\behaviors\HasStatus;
use skeeks\cms\models\behaviors\Implode;
use skeeks\cms\models\Core;
/** /**
* Login form * Class FormEmail
* @package skeeks\modules\cms\form\models
*/ */
class FormEmail extends Model class FormEmail extends Core
{ {
public $value; /**
* @inheritdoc
*/
public static function tableName()
{
return '{{%form_email}}';
}
/**
* @inheritdoc
*/
public function behaviors()
{
return array_merge(parent::behaviors(), []);
}
/** /**
* @inheritdoc * @inheritdoc
*/ */
public function rules() public function rules()
{ {
return [ return array_merge(parent::rules(), [
// username and password are both required [['value', 'form_id'], 'required'],
[['value'], 'required'], [['value'], 'string', 'max' => 255],
// rememberMe must be a boolean value [['form_id', 'value'], 'unique', 'targetAttribute' => ['form_id', 'value'], 'message' => 'The combination of Value and Form ID has already been taken.'],
['value', 'email'], [['value'], 'email'],
]; ]);
}
public function scenarios()
{
$scenarios = parent::scenarios();
$scenarios['create'] = $scenarios[self::SCENARIO_DEFAULT];
$scenarios['update'] = $scenarios[self::SCENARIO_DEFAULT];
return $scenarios;
} }
/**
* @inheritdoc
*/
public function attributeLabels()
{
return array_merge(parent::attributeLabels(), [
'id' => \Yii::t('app', 'ID'),
'value' => \Yii::t('app', 'Email'),
'form_id' => \Yii::t('app', 'Форма'),
]);
}
} }
\ No newline at end of file
<?php
/**
* LoginForm
*
* @author Semenov Alexander <semenov@skeeks.com>
* @link http://skeeks.com/
* @copyright 2010-2014 SkeekS (Sx)
* @date 28.10.2014
* @since 1.0.0
*/
namespace skeeks\modules\cms\form\models\forms;
use Yii;
use yii\base\Model;
/**
* Login form
*/
class EmailForm extends Model
{
public $value;
/**
* @inheritdoc
*/
public function rules()
{
return [
// username and password are both required
[['value'], 'required'],
// rememberMe must be a boolean value
['value', 'email'],
];
}
}
<?php <?php
use yii\helpers\Html; use yii\helpers\Html;
use skeeks\cms\modules\admin\widgets\form\ActiveFormStyled as ActiveForm; use skeeks\cms\modules\admin\widgets\ActiveForm;
use skeeks\cms\models\Tree; use common\models\User;
use skeeks\cms\modules\admin\widgets\Pjax;
/* @var $this yii\web\View */ /* @var $this yii\web\View */
/* @var $model Tree */ /* @var $model \yii\db\ActiveRecord */
/* @var $console \skeeks\cms\controllers\AdminUserController */
?> ?>
<?php $form = ActiveForm::begin(); ?> <?php $form = ActiveForm::begin(); ?>
<?= $form->field($model, 'name')->textInput(['maxlength' => 255]) ?> <?php ?>
<?= $form->buttonsCreateOrUpdate($model); ?>
<?php ActiveForm::end(); ?> <?= $form->fieldSet('Общая ниформация')?>
<?= $form->field($model, 'name')->textInput(); ?>
<?= $form->fieldSetEnd(); ?>
<?= \skeeks\cms\modules\admin\widgets\RelatedModelsGrid::widget([
'label' => "Email адреса",
'hint' => "Укажите email адреса, на которые будут приходить уведомления об отправке формы.",
'parentModel' => $model,
'relation' => [
'form_id' => 'id'
],
'controllerRoute' => 'form/admin-form-email',
'gridViewOptions' => [
'columns' => [
//['class' => 'yii\grid\SerialColumn'],
'value',
],
],
]); ?>
<?= \skeeks\cms\modules\admin\widgets\RelatedModelsGrid::widget([
'label' => "Телефоны",
'hint' => "Укажите телефоны, на которые будут приходить уведомления об отправке формы.",
'parentModel' => $model,
'relation' => [
'form_id' => 'id'
],
'controllerRoute' => 'form/admin-form-phone',
'gridViewOptions' => [
'columns' => [
//['class' => 'yii\grid\SerialColumn'],
'value',
],
],
]); ?>
<?= \skeeks\cms\modules\admin\widgets\RelatedModelsGrid::widget([
'label' => "Элементы формы",
'hint' => "",
'parentModel' => $model,
'relation' => [
'form_id' => 'id'
],
'controllerRoute' => 'form/admin-form-field',
'gridViewOptions' => [
'columns' => [
//['class' => 'yii\grid\SerialColumn'],
'value',
],
],
]); ?>
<?= $form->buttonsCreateOrUpdate($model); ?>
<?php ActiveForm::end(); ?>
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment