I have an interesting problem. In a filter I need to display employees by their status (fired or active, this is stored in the DB). If you don’t type anything in the filter input, it should only show active employees. But if you start typing anything, it should show every employee, including the fired ones
I tried to find how to add classes to filter, so I could just add d-none to them and then remove those when something is typed in the filter input, but I didn’t find how to do this
I tried adding ‘options’ => [‘class’ => ‘d-none’] in ‘filterWidgetOptions’. But I don’t know if it will even work, since if you press ‘select all’ those that are hidden will also be selected
I also tried adding something like this
ArrayHelper::map(
isset($searchModel->value_id) ?
Value::find()->where()->all();
:
Value::find()->all;
and so on
But it’s not going to work neither, because it is only going to work after I add something to the search model
Thanks for the suggestions and I’m sorry for describing my problem this badly
I already had a select2 snippet as well as model and a searchModel.
I only needed to show active employees when nothing was typed in select2 input form and show all active and inactive employees that there is when select2 input contains text.
So what I really needed was modified search for a single select2 form