Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
skeeks
/
cms-module-form
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Merge Requests
0
Pipelines
Members
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit
0388e8aa
authored
Mar 13, 2015
by
semenov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Новая форма для админки с табами ActiveFormUseTab
parent
cd3f8a7a
Hide whitespace changes
Inline
Side-by-side
Showing
9 changed files
with
93 additions
and
11 deletions
+93
-11
config/admin/menu.php
+1
-1
controllers/AdminFormFieldController.php
+0
-1
migrations/m150307_162735_create_form_field_table.php
+3
-0
models/FormField.php
+27
-2
views/admin-form-email/_form.php
+14
-1
views/admin-form-field/_form.php
+17
-2
views/admin-form-phone/_form.php
+14
-1
views/admin-form-send-message/_form.php
+13
-1
views/admin-form/_form.php
+4
-2
No files found.
config/admin/menu.php
View file @
0388e8aa
<?php
fltkf
<?php
/**
* @author Semenov Alexander <semenov@skeeks.com>
* @link http://skeeks.com/
...
...
controllers/AdminFormFieldController.php
View file @
0388e8aa
...
...
@@ -24,7 +24,6 @@ class AdminFormFieldController extends AdminModelEditorSmartController
public
function
init
()
{
$this
->
_label
=
"Управление email форм"
;
$this
->
_modelShowAttribute
=
"value"
;
$this
->
_modelClassName
=
FormField
::
className
();
$this
->
modelValidate
=
true
;
$this
->
enableScenarios
=
true
;
...
...
migrations/m150307_162735_create_form_field_table.php
View file @
0388e8aa
...
...
@@ -38,6 +38,8 @@ class m150307_162735_create_form_field_table extends Migration
'widget'
=>
Schema
::
TYPE_TEXT
.
' NULL'
,
'rules'
=>
Schema
::
TYPE_TEXT
.
' NULL'
,
'priority'
=>
Schema
::
TYPE_INTEGER
.
' NOT NULL DEFAULT 0'
,
'attribute'
=>
Schema
::
TYPE_STRING
.
'(255) NOT NULL'
,
'form_id'
=>
Schema
::
TYPE_INTEGER
.
'(255) NOT NULL'
,
...
...
@@ -50,6 +52,7 @@ class m150307_162735_create_form_field_table extends Migration
$this
->
execute
(
"ALTER TABLE
{
{%form_field}
}
ADD INDEX(updated_at);"
);
$this
->
execute
(
"ALTER TABLE
{
{%form_field}
}
ADD INDEX(label);"
);
$this
->
execute
(
"ALTER TABLE
{
{%form_field}
}
ADD INDEX(priority);"
);
$this
->
execute
(
"ALTER TABLE
{
{%form_field}
}
ADD UNIQUE(attribute,form_id);"
);
$this
->
execute
(
"ALTER TABLE
{
{%form_field}
}
COMMENT = 'Элементы форм';"
);
...
...
models/FormField.php
View file @
0388e8aa
...
...
@@ -42,14 +42,20 @@ class FormField extends Core
{
return
array_merge
(
parent
::
rules
(),
[
[[
'created_by'
,
'updated_by'
,
'created_at'
,
'updated_at'
,
'form_id'
],
'integer'
],
[[
'hint'
,
'widget'
,
'rules'
],
'string'
],
[[
'attribute'
,
'form_id'
],
'required'
],
[[
'hint'
],
'string'
],
[[
'widget'
,
'rules'
],
'safe'
],
[[
'form_id'
],
'required'
],
[
'attribute'
,
'default'
,
'value'
=>
function
(
FormField
$model
,
$attribute
)
{
return
"sx-field-"
.
md5
(
rand
(
1
,
10
)
.
time
());
}],
[[
'label'
,
'attribute'
],
'string'
,
'max'
=>
255
],
[[
'attribute'
,
'form_id'
],
'unique'
,
'targetAttribute'
=>
[
'attribute'
,
'form_id'
],
'message'
=>
'Этот элемент уже привязан к форме'
]
]);
}
public
function
scenarios
()
{
$scenarios
=
parent
::
scenarios
();
...
...
@@ -69,7 +75,25 @@ class FormField extends Core
'id'
=>
\Yii
::
t
(
'app'
,
'ID'
),
'value'
=>
\Yii
::
t
(
'app'
,
'Email'
),
'form_id'
=>
\Yii
::
t
(
'app'
,
'Форма'
),
'attribute'
=>
\Yii
::
t
(
'app'
,
'Уникальный код (необязательно)'
),
'hint'
=>
\Yii
::
t
(
'app'
,
'Небольшая подсказка элемента'
),
'label'
=>
\Yii
::
t
(
'app'
,
'Название'
),
]);
}
/**
* @return \yii\db\ActiveQuery
*/
public
function
findForm
()
{
return
$this
->
hasOne
(
Form
::
className
(),
[
'id'
=>
'form_id'
]);
}
/**
* @return Form
*/
public
function
fetchForm
()
{
return
$this
->
findForm
()
->
one
();
}
}
\ No newline at end of file
views/admin-form-email/_form.php
View file @
0388e8aa
...
...
@@ -13,7 +13,20 @@ use common\models\User;
<?php
$form
=
ActiveForm
::
begin
();
?>
<?php
?>
<?=
$form
->
field
(
$model
,
'form_id'
)
->
hiddenInput
([
'value'
=>
(
int
)
\Yii
::
$app
->
request
->
get
(
'form_id'
)])
->
label
(
false
);
?>
<?
if
(
$form_id
=
\Yii
::
$app
->
request
->
get
(
'form_id'
))
:
?>
<?=
$form
->
field
(
$model
,
'form_id'
)
->
hiddenInput
([
'value'
=>
$form_id
])
->
label
(
false
);
?>
<?
else
:
?>
<?=
$form
->
field
(
$model
,
'form_id'
)
->
label
(
'Форма'
)
->
widget
(
\skeeks\widget\chosen\Chosen
::
className
(),
[
'items'
=>
\yii\helpers\ArrayHelper
::
map
(
\skeeks\modules\cms\form\models\Form
::
find
()
->
all
(),
"id"
,
"name"
),
]);
?>
<?
endif
;
?>
<?=
$form
->
field
(
$model
,
'value'
)
->
textInput
();
?>
<?=
$form
->
buttonsCreateOrUpdate
(
$model
);
?>
...
...
views/admin-form-field/_form.php
View file @
0388e8aa
...
...
@@ -13,8 +13,23 @@ use common\models\User;
<?php
$form
=
ActiveForm
::
begin
();
?>
<?php
?>
<?=
$form
->
field
(
$model
,
'form_id'
)
->
hiddenInput
([
'value'
=>
(
int
)
\Yii
::
$app
->
request
->
get
(
'form_id'
)])
->
label
(
false
);
?>
<?=
$form
->
field
(
$model
,
'value'
)
->
textInput
();
?>
<?
if
(
$form_id
=
\Yii
::
$app
->
request
->
get
(
'form_id'
))
:
?>
<?=
$form
->
field
(
$model
,
'form_id'
)
->
hiddenInput
([
'value'
=>
$form_id
])
->
label
(
false
);
?>
<?
else
:
?>
<?=
$form
->
field
(
$model
,
'form_id'
)
->
label
(
'Форма'
)
->
widget
(
\skeeks\widget\chosen\Chosen
::
className
(),
[
'items'
=>
\yii\helpers\ArrayHelper
::
map
(
\skeeks\modules\cms\form\models\Form
::
find
()
->
all
(),
"id"
,
"name"
),
]);
?>
<?
endif
;
?>
<?=
$form
->
field
(
$model
,
'attribute'
)
->
textInput
();
?>
<?=
$form
->
field
(
$model
,
'label'
)
->
textInput
();
?>
<?=
$form
->
field
(
$model
,
'hint'
)
->
textInput
();
?>
<?=
$form
->
buttonsCreateOrUpdate
(
$model
);
?>
<?php
ActiveForm
::
end
();
?>
views/admin-form-phone/_form.php
View file @
0388e8aa
...
...
@@ -13,7 +13,20 @@ use common\models\User;
<?php
$form
=
ActiveForm
::
begin
();
?>
<?php
?>
<?=
$form
->
field
(
$model
,
'form_id'
)
->
hiddenInput
([
'value'
=>
(
int
)
\Yii
::
$app
->
request
->
get
(
'form_id'
)])
->
label
(
false
);
?>
<?
if
(
$form_id
=
\Yii
::
$app
->
request
->
get
(
'form_id'
))
:
?>
<?=
$form
->
field
(
$model
,
'form_id'
)
->
hiddenInput
([
'value'
=>
$form_id
])
->
label
(
false
);
?>
<?
else
:
?>
<?=
$form
->
field
(
$model
,
'form_id'
)
->
label
(
'Форма'
)
->
widget
(
\skeeks\widget\chosen\Chosen
::
className
(),
[
'items'
=>
\yii\helpers\ArrayHelper
::
map
(
\skeeks\modules\cms\form\models\Form
::
find
()
->
all
(),
"id"
,
"name"
),
]);
?>
<?
endif
;
?>
<?=
$form
->
field
(
$model
,
'value'
)
->
textInput
();
?>
<?=
$form
->
buttonsCreateOrUpdate
(
$model
);
?>
...
...
views/admin-form-send-message/_form.php
View file @
0388e8aa
...
...
@@ -13,7 +13,19 @@ use common\models\User;
<?php
$form
=
ActiveForm
::
begin
();
?>
<?php
?>
<?=
$form
->
field
(
$model
,
'form_id'
)
->
hiddenInput
([
'value'
=>
(
int
)
\Yii
::
$app
->
request
->
get
(
'form_id'
)])
->
label
(
false
);
?>
<?
if
(
$form_id
=
\Yii
::
$app
->
request
->
get
(
'form_id'
))
:
?>
<?=
$form
->
field
(
$model
,
'form_id'
)
->
hiddenInput
([
'value'
=>
$form_id
])
->
label
(
false
);
?>
<?
else
:
?>
<?=
$form
->
field
(
$model
,
'form_id'
)
->
label
(
'Форма'
)
->
widget
(
\skeeks\widget\chosen\Chosen
::
className
(),
[
'items'
=>
\yii\helpers\ArrayHelper
::
map
(
\skeeks\modules\cms\form\models\Form
::
find
()
->
all
(),
"id"
,
"name"
),
]);
?>
<?
endif
;
?>
<?=
$form
->
buttonsCreateOrUpdate
(
$model
);
?>
<?php
ActiveForm
::
end
();
?>
views/admin-form/_form.php
View file @
0388e8aa
<?php
use
yii\helpers\Html
;
use
skeeks\cms\modules\admin\widgets\form\ActiveForm
Styled
as
ActiveForm
;
use
skeeks\cms\modules\admin\widgets\form\ActiveForm
UseTab
as
ActiveForm
;
use
common\models\User
;
/* @var $this yii\web\View */
...
...
@@ -66,7 +66,9 @@ use common\models\User;
'gridViewOptions'
=>
[
'columns'
=>
[
//['class' => 'yii\grid\SerialColumn'],
'value'
,
'attribute'
,
'label'
,
'hint'
,
],
],
]);
?>
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment