Here i like to explain my problem clearly,
am trying to perform multi select dropdown filter, before this multiselect filter i have a basic filter.
Am using kartik-v dropdown extension
search.php
<?php
$status = ArrayHelper::map(Status::find()->all(),'id','status');
echo $form->field($model, 'status')->widget(Select2::classname(), [
'data' => $status,
'language' => 'en',
'options' => [
'placeholder' => 'Select Status..',
'multiple' => true
],
'pluginOptions' => [
'allowClear' => true
],
]);
?>
claimsSearch.php
$query->andFilterWhere([
'status' => $this->status
]);
if i try the above code am getting error as below
Array to string conversion
but here i don't know how to write filter code.
update searchview:
Try to delete 'status' from EmployeeSearch rules. You cannot filter such field automatic way. Or you must set up custom filter value for status column, like this (you can dig into this direction):
How can I use a simple Dropdown list in the search box of GridView::widget, Yii2? Try this link
You are not calling the model in that widget. You shoudl use like this:
echo $form->field($mySearchModel, 'state_10')->widget(Select2::classname(), [
'data' => $status,
'options' => [
'placeholder' => 'Select Status ...',
'multiple' => true
],
]);
And your select it's probably returning an array. So, your search would be something like:
$query->andFilterWhere([
'status' => ('in', 'status', $this->status)
]);
See more examples of queries here.
If that solution don't work, i will sugest you to do a var_dump($yourModel->status)
in your view, just to check what is returning.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With