create/edit a field as an array of comma separated values

create/edit a field as an array of comma separated values

gemifevabegemifevabe Posts: 1Questions: 0Answers: 0

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

  • allanallan Posts: 61,635Questions: 1Answers: 10,092 Site admin

    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

This discussion has been closed.