editor arrays Id to name in other table
editor arrays Id to name in other table
Hello i try to search how i do it, but i didn't find i am using select2 multiple so it insert to the db like this 1|2
and i want to select it and to take this id and check them in other table there name and print
for example
1 table that look with ID,Users (need to be insert here 1|2|3)
and take this 1|2|3 go to other table that have ID,Name
and print the name.
I think that i need to use
->getFormatter( 'Format::explode' )
with
->options( Options::inst()
->table( '' )
->value( '' )
->label( '')
->where( function ( $q ) use ( $yourQueryArray) {
$q->where( '', $yourQueryArray, 'IN');
} )
buy how i take the array from getformatter to use where "yourQueryArray" or there is other options ?
Thanks!
This question has accepted answers - jump to:
Answers
Can you show me how you have configured the field on the client-side? Have your used the
separator
option?Allan
no i didnt used it, this is me client side:
{
"label": "Parts:",
"name": "Parts",
"type": "select2",
"opts": { multiple: true,placeholder: 'Select Parts' }
}
but what i sow you up in the server side its only what i think that i need to do, i didnt doit also becouse i dont know how to use the field that i am select in the where
The problem for its its only from the server side that its take it with the ID and i want to take this ID and draw the name in other table, the id connect between two of them
The select2 plug-in for Editor has a
separator
option which you can set to be|
if you want to pipe separate the values.Allan
i know but my problem was to take the string id from the db and make its name from other table.
In the end I succeeded , i pass in the ->getFormatter the string (ex :1,2) to other function, and there i take the string make him array and did query with :array in.
its work for me, but i want to know if there more options do to it?
That sounds like a good option. If you are working with one-to-many then the
Mjoin
would be a way to do this (typically one-to-many is used with arrays which lends itself to this kind of thing), but I'm not clear if you are using one-to-many data points here.Allan