Skip to content
This repository was archived by the owner on Sep 19, 2023. It is now read-only.

Commit 814ed86

Browse files
committed
no impossible to add items in lists
1 parent 9d25de7 commit 814ed86

File tree

2 files changed

+4
-1
lines changed

2 files changed

+4
-1
lines changed

src/views/permissions/_form.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,7 @@
7373
'emptyMsg' => 'Permission is not assigned to any roles.',
7474
'searchMsg' => 'Search roles...',
7575
'options' => \justcoded\yii2\rbac\models\Role::getList(),
76+
'opposite' => [],
7677
'selected' => $permission->getRoles(),
7778
'btnTxt' => 'Assign',
7879
]);
@@ -86,6 +87,7 @@
8687
'emptyMsg' => 'Permission doesn\'t have parents.',
8788
'searchMsg' => 'Search permissions...',
8889
'options' => \justcoded\yii2\rbac\models\Permission::getList(),
90+
'opposite' => $permission->getChildren(),
8991
'selected' => $permission->getParents(),
9092
'btnTxt' => 'Add Parents',
9193
]);
@@ -99,6 +101,7 @@
99101
'emptyMsg' => 'Permission doesn\'t have children.',
100102
'searchMsg' => 'Search permissions...',
101103
'options' => \justcoded\yii2\rbac\models\Permission::getList(),
104+
'opposite' => $permission->getParents(),
102105
'selected' => $permission->getChildren(),
103106
'btnTxt' => 'Add Childs',
104107
]); ?>

src/views/permissions/_relations-box.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@
6464
<?= Select2::widget([
6565
'model' => $relModel,
6666
'attribute' => 'names',
67-
'data' => array_diff($options, array_keys($selected), [$model->name]),
67+
'data' => array_diff($options, array_keys(array_merge($selected, $opposite)), [$model->name]),
6868
'options' => [
6969
'id' => $form->id . '-search',
7070
'placeholder' => $searchMsg,

0 commit comments

Comments
 (0)