Answer the question
In order to leave comments, you need to log in
Is it possible to do something similar in the control panel?
Is it possible to do something similar in the control panel?
Especially where to copy, move or other actions, but preferably without Grid.
You can provide a sample code in Yii2 or where you can read how to do this.
PS
I'm not interested in layout, but in the checkbox submission form along with the choice of a specific action for the selected checkboxes, such as move, copy, and others.
$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']);
Answer the question
In order to leave comments, you need to log in
Is it possible to do something similar in the control panel?
I'm not interested in layout, but in the checkbox submission form along with the choice of a specific action for the selected checkboxes, such as move, copy, and others.
$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']);
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question