create/edit a field as an array of comma separated values
create/edit a field as an array of comma separated values
I have a field which is populated from my mongodb database, where it is an array of objects.
It is correctly being displayed using []
:
var editor = new $.fn.dataTable.Editor({
ajaxUrl: '/some/path,
domTable: '#example',
dbTable: 'shopping',
idSrc: '_id',
fields: [{
label: 'My array field:',
name: 'shopping.list[].item'
}
the field gets populated like this: cookies,fruit,coca,orange,water
but when I create a new record or edit an existing one, the data gets passed down and saved letter by letter:
[{item:"c"},{item:"o"},{item:"o"},{item:"k"},{item:"i"},{item:"e"},{item:"s"},{item:","},{item:"f"}, ... ]
what is the solution to pass comma seperated values and recognize them as arrays?
Replies
That's using a plain text input, so my question is, how is this being saved on the database site of things? Do the list objects have more than just
item
in them, which would make things more interesting / complicated.Thanks
Allan