chosen plugin with multiselect
chosen plugin with multiselect

I'm writing an app with node.js. I've also installed the chosen plugin with the datatables editor and I'm using it with the multiselect option turned on. After entering more than one options into the multiselection field and pressing the update button in the editor, the debugger breaks with following exception message:
Error: update users
set username
= 'rolf', department
= 'asdf', roles
= '2', '3' where id
= '6' - ER_PARSE_ERROR: You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax (shortened)
The error results from the wrong concatenation of the activated multiselect options. I've also tried out several settings for the separator.
Here's the field definition:
{
label: 'Roles:',
name: 'roles',
type: 'chosen',
separator: '|',
attr: {
multiple: 'true',
},
options: [
{ label: "A", value: 1 },
{ label: "B", value: 2 },
{ label: "C", value: 3 },
{ label: "D", value: 4 },
{ label: "E", value: 5 }
]
},
Any ideas?
This question has an accepted answers - jump to answer
Answers
This looks wrong:
If you have a pipe separator I'd expect it to be submitting
2|3
from the client-side and that should be what is written to the db (unless there is some other processing going on with the server for collections?).Have a look at the Ajax request in your browser's network inspector and see what it is actually sending to the server.
Thanks,
Allan
Hi Allan
Thank you for your fast response. I am an absolute beginner in nodejs and javascript development, and appreciate any help.
The client-side ajax request looks like
According to your last post I would expect something like:
I've also tried to put the separator attribute into the attr-group:
with the same result. The separator attribute does not seem to be taken into account, the client sends an array instead of a string.
You can find a test case here:
http://www.koch-motta.ch:8000/users
Thanks
Rolf
Ah! I see the problem - this is using Chosen. Could you try it temporarily with the built in
select
option? Our plug-in for Chosen doesn't supportseparator
at the moment.Allan
Thank you Allan!
Indeed, the problem is solved by switching to the built in select field type, as
This works, but looks ugly, as you can see in the test case.
In this case I'll have to wait until one of the next versions of the editor supports separators in the Chosen plugin?
Cheers,
Rolf