G
G
Ghost26922018-01-28 00:45:35
Yii
Ghost2692, 2018-01-28 00:45:35

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.
5a6cf2cc3f09c494532984.png5a6cf2d5e2b3d288900025.png
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();
                        }
                    }
                }
            }
        }

the first one changes the status to 0 and the second deletes the record
<?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']);

the problem is that there is one form, and many modal windows (copy, move, and others) to send data, in accordance, all data is sent to delete or move, and only the rest of the code is executed.
As I understand it, in php you can submit only one form and not 2 or more.

Answer the question

In order to leave comments, you need to log in

2 answer(s)
M
Maxim Timofeev, 2018-01-28
@webinar

Is it possible to do something similar in the control panel?

There is no control panel in yii2, please describe what you mean by this term. But the screen is a regular table, with some kind of template similar to https://adminlte.io/themes/AdminLTE/index2.html But this is a layout issue, not yii.
What?
Surely, to understand what it is? There is a suspicion that you are interested in ui elements, but they are implemented on the front, and yii is a backend framework. You seem to be confusing layout with backend. If "I want it to look like this" - this is js + html + css.
And grid has something to do with it, and again, this is a layout issue. You want to change the wallpaper, but for some reason you dismantled the refrigerator. These things are not connected in any way.

G
Ghost2692, 2018-01-28
@Ghost2692

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();
                        }
                    }
                }
            }
        }

the first one changes the status to 0 and the second deletes the record
<?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']);

the problem is that there is one form, and many modal windows (copy, move, and others) to send data, in accordance, all data is sent to delete or move, and only the rest of the code is executed.
As I understand it, in php you can submit only one form and not 2 or more.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question