$changeOnUnsubscribed = new ContactList();
if ($changeOnUnsubscribed->load(Yii::$app->request->post())) {
$contactId = ContactList::find()->where(['contact_id' => $id])->all();
foreach ($contactId as $id) {
$count = count($changeOnUnsubscribed->selected_checkbox);
for ($i = 1; $i < $count; $i++) {
$item = $changeOnUnsubscribed->selected_checkbox[$i];
if ($item != 0) {
if ($item == $id->id) {
$ids = ContactList::findOne($id->id);
$ids->status = 0;
$ids->save(false);
}
}
}
}
}
// delete all selected contact
$deleteContacts = new ContactList();
if ($deleteContacts->load(Yii::$app->request->post())) {
$contactId = ContactList::find()->where(['contact_id' => $id])->all();
foreach ($contactId as $id) {
$count = count($deleteContacts->selected_checkbox);
for ($i = 1; $i < $count; $i++) {
$item = $deleteContacts->selected_checkbox[$i];
if ($item != 0) {
if ($item == $id->id) {
$ids = ContactList::findOne($id->id);
$ids->delete();
}
}
}
}
}
<?php if ($contactList) { ?>
<?php $form = ActiveForm::begin([
'method' => 'post',
'id' => 'checkbox-contact',
'options' => ['class' => 'form-inline']
]); ?>
<?php foreach ($contactList as $contact): ?>
<tr>
<td>
<?= $form->field($selectContact, 'selected_checkbox[]')->checkbox(['id' => $contact->id, 'class' => 'checkbox-contact-list form-check-input position-static', 'value' => $contact->id, 'label' => null]) ?>
</td>
<?php endforeach; ?>
//modal window
$items = ArrayHelper::map($groupContactList,'id','name_group');
$params = [ 'prompt' => Yii::t('app', 'Choose...') ];
echo $form->field($selectContact, 'group')->dropDownList($items,$params)->label(Yii::t('app', 'Select a group') . ':', ['class' => 'col-form-label']);
Можно сделать что-то похожее в панель управлении?
Особенно где копировать, переместить
Можете привести образец кода на Yii2 или где можно почитать как сделать такое
желательно без Grid
$changeOnUnsubscribed = new ContactList();
if ($changeOnUnsubscribed->load(Yii::$app->request->post())) {
$contactId = ContactList::find()->where(['contact_id' => $id])->all();
foreach ($contactId as $id) {
$count = count($changeOnUnsubscribed->selected_checkbox);
for ($i = 1; $i < $count; $i++) {
$item = $changeOnUnsubscribed->selected_checkbox[$i];
if ($item != 0) {
if ($item == $id->id) {
$ids = ContactList::findOne($id->id);
$ids->status = 0;
$ids->save(false);
}
}
}
}
}
// delete all selected contact
$deleteContacts = new ContactList();
if ($deleteContacts->load(Yii::$app->request->post())) {
$contactId = ContactList::find()->where(['contact_id' => $id])->all();
foreach ($contactId as $id) {
$count = count($deleteContacts->selected_checkbox);
for ($i = 1; $i < $count; $i++) {
$item = $deleteContacts->selected_checkbox[$i];
if ($item != 0) {
if ($item == $id->id) {
$ids = ContactList::findOne($id->id);
$ids->delete();
}
}
}
}
}
<?php if ($contactList) { ?>
<?php $form = ActiveForm::begin([
'method' => 'post',
'id' => 'checkbox-contact',
'options' => ['class' => 'form-inline']
]); ?>
<?php foreach ($contactList as $contact): ?>
<tr>
<td>
<?= $form->field($selectContact, 'selected_checkbox[]')->checkbox(['id' => $contact->id, 'class' => 'checkbox-contact-list form-check-input position-static', 'value' => $contact->id, 'label' => null]) ?>
</td>
<?php endforeach; ?>
//modal window
$items = ArrayHelper::map($groupContactList,'id','name_group');
$params = [ 'prompt' => Yii::t('app', 'Choose...') ];
echo $form->field($selectContact, 'group')->dropDownList($items,$params)->label(Yii::t('app', 'Select a group') . ':', ['class' => 'col-form-label']);