У меня выводится такие данные
<?php foreach ($contactList as $contact): ?>
<tr>
<td>
<div class="form-check">
<label class="form-check-label">
<input class="form-check-input position-static" type="checkbox" value="option1">
</label>
</div>
</td>
<td><?= $contact->email_address ?></td>
<td>
<?php if ($contact->name == null): ?>
<!-- Modal name contact -->
<div class="modal fade" id="nameContact" tabindex="-1" role="dialog" aria-labelledby="nameContact"
aria-hidden="true">
<div class="modal-dialog" role="document">
<div class="modal-content">
<div class="modal-header">
<h5 class="modal-title"
id="nameContactLabel"><?= Yii::t('app', 'Add a contact name') ?></h5>
<button type="button" class="close" data-dismiss="modal" aria-label="Close">
<span aria-hidden="true">×</span>
</button>
</div>
<div class="modal-body">
<?php $form = ActiveForm::begin([
'method' => 'post',
'id' => 'name-contact'
]); ?>
<?= $form->field($nameContact, 'name_contact')->textInput(['class' => 'form-control'])->label(Yii::t('app', 'Contact name') . ':', ['class' => 'col-form-label']) ?>
<?php ActiveForm::end(); ?>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-sm btn-main" data-dismiss="modal">
<?= Yii::t('app', 'Close') ?>
</button>
<?= Html::submitButton(Yii::t('app', 'Save changes'), ['class' => 'btn btn-sm button-success', 'form' => 'name-contact']) ?>
</div>
</div>
</div>
</div>
<i class="material-icons icon-button" style="cursor: pointer" data-toggle="modal" data-target="#nameContact">add_circle_outline</i>
<?php else: ?>
<?= $contact->name ?>
<?php endif; ?>
</td>
<td>
<?php if ($contact->phone == null): ?>
<i class="material-icons icon-button">add_circle_outline</i>
<?php else: ?>
<?= $contact->phone ?>
<?php endif; ?>
</td>
<td><?= $contact->created ?></td>
</tr>
<?php endforeach; ?>
в модели сохраняет только для первого id
public function saveNameContact($id){
$name = ContactList::find()
->where(['contact_id' => $id])
->with('groupContactList')
->one();
if (isset($this->name_contact)){
$name->name = Html::encode($this->name_contact);
return $name->save();
}
}
Мне нужно сохранить введенные данные з модального окна в базу для конкретного поля, как это сделать?