Tailor Taglist Cannot Be Filtered In List View
sqwk opened this issue · comments
I am using tailor to create a taglist field. This field cannot be filtered in the backend list view and displays the error We're sorry, but something went wrong and the page cannot be displayed.
when clicking the filter in question. The error log gives a little more info and says Error: Call to a member function newQuery() on null in /.../modules/backend/filterwidgets/Group.php:196
.
This is the field blueprint:
type: structure
fields:
foo:
label: Foo
type: taglist
customTags: false
useKey: true
options:
tag1: Tag 1
tag2: Tag 2
tag3: Tag 3
validation:
- required
tab: Main
column:
label: Foo
invisible: true
scope:
label: Foo
Using type:dropdown
instead of type:taglist
works as expected.
Hi @sqwk
The next patch will include a fix for this (v3.5.14). After updating, set the mode
to array so it can be searched with the group filter. For example:
foo:
label: Foo
type: taglist
mode: array
Thanks!
I installed the update. Renderering the taglist works fine, applying a filter does not:
PDOException: SQLSTATE[22032]: <<Unknown error>>: 3141 Invalid JSON text in argument 1 to function json_contains: "Invalid value." at position 0. in /is/htdocs/wp10607758_UGYQNSM3W9/www/vendor/laravel/framework/src/Illuminate/Database/Connection.php:419
The whole field definition is now:
fields:
foo:
label: Foo?
type: taglist
mode: array
customTags: false
useKey: true
options:
tag1: Tag 1
tag2: Tag 2
tag3: Tag 3
validation:
- required
tab: Main
column:
label: Foo
invisible: true
scope:
label: Foo
span: row
spanClass: col-12 col-md-4
Hey @sqwk
The error suggests the database still contains a "string" value, so it can't be queried as JSON. We may need to lock mode
to array
to prevent this scenario. In your case, you'll need to update every record after making this change to ensure it is set to a valid JSON value for SQL to query.
So instead of tag1,tag2
it should be be ['tag1','tag2']
?