Commit 27f8af79293a6a1681164cf389ed4b70cd9eba6c
1 parent
0ae6f109
test
Showing
4 changed files
with
59 additions
and
0 deletions
Show diff stats
backend/web/js/option.js
@@ -126,6 +126,13 @@ $(function() { | @@ -126,6 +126,13 @@ $(function() { | ||
126 | $(this).parents('.checkboxer').find('.checkboxer_container').removeClass('active'); | 126 | $(this).parents('.checkboxer').find('.checkboxer_container').removeClass('active'); |
127 | $(this).parents('.checkboxer_container').addClass('active'); | 127 | $(this).parents('.checkboxer_container').addClass('active'); |
128 | }); | 128 | }); |
129 | + $(document).on('click', '.add_column a', function() { | ||
130 | + var container = $(this).parent().parent(); | ||
131 | + var clone = $(container).clone(); | ||
132 | + clone.find('.add_column').remove(); | ||
133 | + $(clone).insertAfter(container); | ||
134 | + return false; | ||
135 | + }); | ||
129 | $.each($('.f32'), function(i, val) { | 136 | $.each($('.f32'), function(i, val) { |
130 | $(val).find('a[role=tab]').first().trigger('click'); | 137 | $(val).find('a[role=tab]').first().trigger('click'); |
131 | }); | 138 | }); |
common/models/OptionHelper.php
@@ -10,8 +10,11 @@ use yii\base\Model; | @@ -10,8 +10,11 @@ use yii\base\Model; | ||
10 | class OptionHelper extends Model | 10 | class OptionHelper extends Model |
11 | { | 11 | { |
12 | const OPTION_OBJECT = 1; | 12 | const OPTION_OBJECT = 1; |
13 | + | ||
13 | const OPTION_ARRAY = 2; | 14 | const OPTION_ARRAY = 2; |
15 | + | ||
14 | const OPTION_VALUE = 3; | 16 | const OPTION_VALUE = 3; |
17 | + | ||
15 | public function getRule($return = 3) | 18 | public function getRule($return = 3) |
16 | { | 19 | { |
17 | $result = Option::find()->where(['name' => 'rules'])->with('value'); | 20 | $result = Option::find()->where(['name' => 'rules'])->with('value'); |
@@ -25,4 +28,15 @@ class OptionHelper extends Model | @@ -25,4 +28,15 @@ class OptionHelper extends Model | ||
25 | throw new InvalidParamException(Yii::t('app', 'Must be 1-3')); | 28 | throw new InvalidParamException(Yii::t('app', 'Must be 1-3')); |
26 | } | 29 | } |
27 | } | 30 | } |
31 | + | ||
32 | + public function createOptions($user_id) | ||
33 | + { | ||
34 | + if($rows_delete = \Yii::$app->db->createCommand()->delete('option', ['model' => 'common\models\User', 'model_id' => $user_id])->execute()) { | ||
35 | + Yii::trace( $rows_delete . " rows has been deleted."); | ||
36 | + } else { | ||
37 | + Yii::trace( "No rows has been deleted" ); | ||
38 | + } | ||
39 | + Yii::$app->db->createCommand()->batchInsert('option', ['model', 'model_id', 'name', 'template', 'option_pid'], [['common\models\User', $user_id, 'about', '']]) | ||
40 | + } | ||
41 | + | ||
28 | } | 42 | } |
common/modules/blog/controllers/AjaxController.php
@@ -129,4 +129,5 @@ class AjaxController extends Controller | @@ -129,4 +129,5 @@ class AjaxController extends Controller | ||
129 | $model = new $model(['language_id' => $language_id]); | 129 | $model = new $model(['language_id' => $language_id]); |
130 | return $this->renderAjax($ajaxView, ['model' => $model, 'widget_id' => $widget_id]); | 130 | return $this->renderAjax($ajaxView, ['model' => $model, 'widget_id' => $widget_id]); |
131 | } | 131 | } |
132 | + | ||
132 | } | 133 | } |
1 | +<?php | ||
2 | + | ||
3 | + use yii\bootstrap\ActiveField; | ||
4 | + use mihaildev\ckeditor\CKEditor; | ||
5 | + | ||
6 | + if(empty($form)) { | ||
7 | + $new_form = true; | ||
8 | + $form = \yii\bootstrap\ActiveForm::begin(); | ||
9 | + } | ||
10 | +?> | ||
11 | + <div role="" class="tab-pane active ajax-loaded" id="<?=$widget_id?>-<?=$model->language_id?>"> | ||
12 | + | ||
13 | + <?php | ||
14 | + /* | ||
15 | + ?> | ||
16 | + <?= (new ActiveField(['model' => $model, 'attribute' => "[$model->language_id]language_id[]", 'form' => $form]))->label(false)->hiddenInput(['value' => $model->language_id]) ?> | ||
17 | + | ||
18 | + <?= (new ActiveField(['model' => $model, 'attribute' => "[$model->language_id]option_id[]", 'form' => $form]))->label(false)->hiddenInput(['value' => $model->option_id]) ?> | ||
19 | + | ||
20 | + <?= (new ActiveField(['model' => $model, 'attribute' => "[$model->language_id]value[]", 'form' => $form, 'template' => "{label}\n{input}\n{hint}\n{error}"]))->textInput() ?> | ||
21 | + <?php | ||
22 | + */ | ||
23 | + ?> | ||
24 | + <?= (new ActiveField([ | ||
25 | + 'model' => $model, | ||
26 | + 'attribute' => "[$model->language_id][2]value[]", | ||
27 | + 'form' => $form, | ||
28 | + 'template' => "{label}\n{input}\n{hint}\n{error}<div class='add_column'><a href=''>Добавить</a></div>", | ||
29 | + ])) | ||
30 | + ->textInput() ?> | ||
31 | + | ||
32 | + </div> | ||
33 | +<?php | ||
34 | + if(isset($new_form) && $new_form === true) { | ||
35 | + $form->end(); | ||
36 | + } | ||
37 | +?> |