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 | 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 | 12 | $row = $i; |
13 | + | |
13 | 14 | ?> |
14 | 15 | |
15 | 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 | 18 | <span data-id="<?= isset($model[$i]['parent_key']) ? $model[$i]['parent_key'] : 0 ?>" title="удалить" class="glyphicon glyphicon-trash delete-field-item"></span> |
18 | 19 | <?= Html::endTag('div')?> |
20 | + <?php $i = ++ $t; ?> | |
19 | 21 | <?php endfor; ?> |
20 | 22 | |
21 | 23 | ... | ... |
frontend/controllers/AccountsController.php
... | ... | @@ -150,7 +150,9 @@ class AccountsController extends Controller |
150 | 150 | |
151 | 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 | 156 | $user_info = UserInfo::find()->where(['user_id' => \Yii::$app->user->getId()])->one(); |
155 | 157 | if(empty($user_info)) { |
156 | 158 | $user_info = new UserInfo(['user_id' => \Yii::$app->user->getId()]); | ... | ... |
frontend/views/accounts/contacts.php