Hi, in general I'm unsure how to ask this question, but please do correct me if I'm totally mistaken!
I have a database structure which has let's say 4 tables
I'm trying to assign multiple users to a team, and assign multiple users as team leaders for a given team and have the users assigned as leaders in one cell, and the members in another.
I've made an image of the database.
Is it possible to do this using datatables, I cannot seem to figure it out, without the rows being duplicated in datatable.
Let me explain a bit more. In the editor, when selecting two users in the dropdown ("type": 'select'), with "mulitple": true, the datatable collects the date correctly, except for the fact that i comes as two rows in the table, one with each name.
The code I'm using is:
Editor::inst( $db, 'Teams', 'id' ) ->fields( Field::inst( 'Users.name' ), Field::inst( 'TeamLeaders.user_id' ) ->options(Options::inst() ->table('Users') ->value('id') ->label('name') ) ) ->leftJoin('TeamLeaders', 'TeamLeaders.team_id', '=', 'Teams.id') ->leftJoin('Users', 'Users.id', '=', 'TeamLeaders.user_id')
Please note that this code might not exactly reflect the image i've added as the database structure is a lot more complex than that.
Thanks in advance!
This question has an accepted answers - jump to answer