I have select2
return $this->form->field($this->model, 'observers')
->widget(Select2::className(),
[
'data' => Tasks::getAllStaffsGroupOffice(),
'disabled' => !$this->can['changeObservers'],
'options' => [
'multiple' => true,
'value' => ArrayHelper::map($this->model->observers, 'staff_id', 'staff_id'),
'placeholder' => Yii::t('tasks_forms', 'FORM_PLACEHOLDER_CHOOSE'),
'class' => 'hiddenInput'
],
'pluginOptions' => [
'allowClear' => true,
'closeOnSelect'=> false,
],
'pluginLoading' => false,
]);
Tasks::getAllStaffsGroupOffice()
geting users array by offices. Example ->
array:4 [▼
"main office" => array:1 [▼
2 => "123 123"
]
"office 1" => array:3 [▼
3 => "staff_1"
6 => "staff_2"
2 => "123 123"
]
"office 3" => array:2 [▼
4 => "staff_3"
3 => "staff_1"
]
"office 2" => array:2 [▼
5 => "staff_4"
3 => "staff_1"
]
]
select2 value example -> array (2 => "2")
As a result, the display of the widget itself looks like this select2 value
How to make it so that the staff which is in 2 and more offices is displayed only 1 time?