Commit 4f1adc01953a212b96e0527acd36e86c889c9a5f
1 parent
df45665b
test
Showing
3 changed files
with
8 additions
and
4 deletions
Show diff stats
common/widgets/views/phone_field.php
@@ -8,14 +8,16 @@ use yii\helpers\Html; | @@ -8,14 +8,16 @@ use yii\helpers\Html; | ||
8 | <p class="btn btn-success add_field">Добавить поле</p> | 8 | <p class="btn btn-success add_field">Добавить поле</p> |
9 | 9 | ||
10 | 10 | ||
11 | - <?php for($i=1; $i <= count($model); $i++): | 11 | + <?php $t = 0; for($i=1; $i <= count($model); $i++): |
12 | $row = $i; | 12 | $row = $i; |
13 | + | ||
13 | ?> | 14 | ?> |
14 | 15 | ||
15 | <?= Html::beginTag('div',['class'=>'form-group','id'=>isset($model[$i]['parent_key']) ? $model[$i]['parent_key'] : 0 ])?> | 16 | <?= Html::beginTag('div',['class'=>'form-group','id'=>isset($model[$i]['parent_key']) ? $model[$i]['parent_key'] : 0 ])?> |
16 | - <input type="text" placeholder="Телефон" class="form-control" value="<?= isset($model[$i]['value']) ? $model[$i]['value'] : '' ?>" name="Fields[phone][<?=$row?>][0][phone]" /> | 17 | + <input type="text" placeholder="Телефон" class="form-control" value="<?= isset($model[$t]['value']) ? $model[$t]['value'] : '' ?>" name="Fields[phone][<?=$row?>][0][phone]" /> |
17 | <span data-id="<?= isset($model[$i]['parent_key']) ? $model[$i]['parent_key'] : 0 ?>" title="удалить" class="glyphicon glyphicon-trash delete-field-item"></span> | 18 | <span data-id="<?= isset($model[$i]['parent_key']) ? $model[$i]['parent_key'] : 0 ?>" title="удалить" class="glyphicon glyphicon-trash delete-field-item"></span> |
18 | <?= Html::endTag('div')?> | 19 | <?= Html::endTag('div')?> |
20 | + <?php $i = ++ $t; ?> | ||
19 | <?php endfor; ?> | 21 | <?php endfor; ?> |
20 | 22 | ||
21 | 23 |
frontend/controllers/AccountsController.php
@@ -150,7 +150,9 @@ class AccountsController extends Controller | @@ -150,7 +150,9 @@ class AccountsController extends Controller | ||
150 | 150 | ||
151 | public function actionContacts() | 151 | public function actionContacts() |
152 | { | 152 | { |
153 | - var_dump(\Yii::$app->request->post()); | 153 | + if(!empty(\Yii::$app->request->post())) { |
154 | + Fields::saveFieldData( Yii::$app->request->post('Fields'), \Yii::$app->user->identity->id, User::className(),'ru'); | ||
155 | + } | ||
154 | $user_info = UserInfo::find()->where(['user_id' => \Yii::$app->user->getId()])->one(); | 156 | $user_info = UserInfo::find()->where(['user_id' => \Yii::$app->user->getId()])->one(); |
155 | if(empty($user_info)) { | 157 | if(empty($user_info)) { |
156 | $user_info = new UserInfo(['user_id' => \Yii::$app->user->getId()]); | 158 | $user_info = new UserInfo(['user_id' => \Yii::$app->user->getId()]); |
frontend/views/accounts/contacts.php
@@ -17,7 +17,7 @@ $form = ActiveForm::begin(); | @@ -17,7 +17,7 @@ $form = ActiveForm::begin(); | ||
17 | 'template'=>'phone', | 17 | 'template'=>'phone', |
18 | 'item_id'=> $user->id, | 18 | 'item_id'=> $user->id, |
19 | 'model'=>'common\models\User', | 19 | 'model'=>'common\models\User', |
20 | - 'language'=>'0' | 20 | + 'language'=>'ru' |
21 | ]); ?> | 21 | ]); ?> |
22 | <?php | 22 | <?php |
23 | echo Html::submitButton('submit'); | 23 | echo Html::submitButton('submit'); |