我需要清楚地解释我的问题 我的应用程序中有状态下拉列表,我尝试使用多选下拉过滤器。
_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
],
]);
?>
modelSearch.php
if($this->status != null)
{
$query->andFilterWhere( "status IN (".implode(',',$this->status).")" );
}
以上是我的代码,当我按下搜索按钮时出现错误
PHP注意事项 - yii \ base \ ErrorException
数组到字符串转换
帮我解决这个问题...
答案 0 :(得分:0)
请在 modelSearch.php
中尝试此操作if($this->status != null)
{
$query->andFilterWhere([ 'in','status',$this->status]);
}