Multiple-value filter inputs (eg. Select2
) throw Array to string conversion
error after filtering
#1079
Open
12 of 17 tasks
Prerequisites
master
branch of yii2-grid.Steps to reproduce the issue
GridView
withActiveDataProvider
that has a column with active filterSelect2
filter with some data andmultiple
input allowed:Expected behavior and actual behavior
When I follow those steps, I see
Array to string conversion
error fromyiisoft/yii2/helpers/BaseHtml.php
at line569
is thrown.I was expecting the filter to be rendered properly with values I selected
Environment
Browsers
Operating System
Libraries
3.6.1
3.5.3
Isolating the problem
Workaround
'filter' => ''
(empty string) for that data column makes the filter work fineReason for the bug and possible solution
kartik\grid\DataColumn
inrenderFilterCellContent()
method starts by callingparent
implementation (so Yii2 nativeDataColumn::renderFilterCellContent()
). All parent implementation does is creating basic dropdown/text input filter, which obviously cannot takearray
dataSelect2
uses. As parent implementation starts by checking iffilter
is a string and returns it instead in such scenario - so thatkartik
implementation can do its own "magic" - it skips the faulty (and unnecessary) native filter creation.Possibly parent call can be omitted when
filterType
is specified or'filter' => ''
could be set by default whenfilterType
is specified? Setting it manually for each column (filter) feels hacky.The text was updated successfully, but these errors were encountered: