Add multiples of one item (users) to a form

arcadeicons

Member
I need to be able to add multiple users to an event.

In my form I currently I have

- auto-complete datajoin element 'guests' for my form table #_add_tournament
- a table called #_add_tournament_repeat_guests

how do I display the "+" option to add other guests in the form?
 
If you've set the group to repeat, it should have the +/-.

Is "Repeat" set to yes in the group settings?

To get a repeat group, you would typically create a new group in the Groups page, assign it to a form, save it, then edit it and set Repeat to yes.

-- hugh
 
I really have no idea what you setup is. As I said, to get a repeat group, you would add a group to an existing form, and set it to repeat. Fabrik will then automagically create a new table for the repeat data, and add a list join to it, and set it to repeat, so you have a one-to-many relationship with a separate table (group).

So you would have two table - 'events' and (say) 'events_123_repeat' (a name Fabri would automatically create).

Or you can do it by hand, by creating another list, which includes a parent_id field, and add a list join from your events list to it manually, joined from main table's 'id' to chile tables 'parent_id', and set repeat to Yes.

-- hugh
 
Or you can do it by hand, by creating another list, which includes a parent_id field, and add a list join from your events list to it manually, joined from main table's 'id' to chile tables 'parent_id', and set repeat to Yes.

OK I have done this and I do have the +/- button but not where I needed it to be in the form which was next to the 'Add Guests (By Name)' field which is an Auto-completing DBJoin
 

Attachments

  • Capture.JPG
    Capture.JPG
    64.9 KB · Views: 103
Well, that's not how it works. :)

You'd have to put the auto-complete join in the repeat group. To add a new guest, you + a group, then set the name.

It might be possible to do it the way you want with some custom JS, sitting on the event that fires when the auto-complete completes, and manually add a group. But that wouldn't be entirely trivial. Do-able, but requires some knowledge of JS and how Fabrik works.

-- hugh
 
OK I moved the guests element over to the 'add-tournament_repeat_guests' group and joined that list to the 'add_tournament' list/group from add_tournament.id to add-tournament_repeat_guests.parentid repeat enabled.

Now I'm getting a 500 error complaining about an unknown column 'add_tournament_repeat_guests.id' which exists.

Code:
500 Fabrik has generated an incorrect query for the list add tournament: <br /><br /><pre>Unknown column 'add_tournament_repeat_guests.id' in 'field list' SQL=SELECT SQL_CALC_FOUND_ROWS DISTINCT `add_tournament`.`date_time` AS `add_tournament___date_time`, `add_tournament`.`date_time` AS `add_tournament___date_time_raw`, `add_tournament`.`id` AS `add_tournament___id`, `add_tournament`.`id` AS `add_tournament___id_raw`, `add_tournament`.`tourn_name` AS `add_tournament___tourn_name`, `add_tournament`.`tourn_name` AS `add_tournament___tourn_name_raw`, `add_tournament`.`collectiontype` AS `add_tournament___collectiontype_raw`, `#__jem_venues`.`venue` AS `add_tournament___collectiontype`, `add_tournament`.`eventID` AS `add_tournament___eventID_raw`, `#__jem_events`.`title` AS `add_tournament___eventID`, `add_tournament`.`cityID` AS `add_tournament___cityID_raw`, CONCAT_WS('', (SELECT city FROM #__jem_venues WHERE #__jem_venues.id = `select_game`.collectiontype)) AS `add_tournament___cityID`, `add_tournament`.`stateID` AS `add_tournament___stateID_raw`, CONCAT_WS('', (SELECT state FROM #__jem_venues WHERE #__jem_venues.id = `select_game_0`.collectiontype)) AS `add_tournament___stateID`, `add_tournament`.`event_start` AS `add_tournament___event_start`, `add_tournament`.`event_start` AS `add_tournament___event_start_raw`, (SELECT GROUP_CONCAT(CONCAT_WS('', (SELECT name FROM #__djc2_items WHERE #__djc2_items.id = `lookup`.gameID)) SEPARATOR '//..*..//') FROM add_tournament_repeat_gameID LEFT JOIN select_game AS lookup ON lookup.id = add_tournament_repeat_gameID.gameID WHERE add_tournament_repeat_gameID.parent_id = add_tournament.id) AS `add_tournament___gameID`, (SELECT GROUP_CONCAT(id SEPARATOR '//..*..//') FROM add_tournament_repeat_gameID WHERE parent_id = add_tournament.id) AS `add_tournament___gameID_raw`, (SELECT GROUP_CONCAT(gameID SEPARATOR '//..*..//') FROM add_tournament_repeat_gameID WHERE add_tournament_repeat_gameID.parent_id = add_tournament.id) AS `add_tournament___gameID_id`, (SELECT GROUP_CONCAT(params SEPARATOR '//..*..//') FROM add_tournament_repeat_gameID WHERE parent_id = add_tournament.id) AS `add_tournament___gameID___params`, (SELECT GROUP_CONCAT(CONCAT_WS('', (SELECT name FROM #__users WHERE #__users.id = `lookup`.uid)) SEPARATOR '//..*..//') FROM add_tournament_repeat_guests LEFT JOIN #__jem_register AS lookup ON lookup.id = add_tournament_repeat_guests.guests WHERE add_tournament_repeat_guests.parent_id = add_tournament.id) AS `add_tournament___guests`, (SELECT GROUP_CONCAT(id SEPARATOR '//..*..//') FROM add_tournament_repeat_guests WHERE parent_id = add_tournament.id) AS `add_tournament___guests_raw`, (SELECT GROUP_CONCAT(guests SEPARATOR '//..*..//') FROM add_tournament_repeat_guests WHERE add_tournament_repeat_guests.parent_id = add_tournament.id) AS `add_tournament___guests_id`, (SELECT GROUP_CONCAT(params SEPARATOR '//..*..//') FROM add_tournament_repeat_guests WHERE parent_id = add_tournament.id) AS `add_tournament___guests___params`, `add_tournament_repeat_guests`.`id` AS `add_tournament_repeat_guests___id`, `add_tournament_repeat_guests`.`id` AS `add_tournament_repeat_guests___id_raw`, `add_tournament_repeat_guests`.`parent_id` AS `add_tournament_repeat_guests___parent_id`, `add_tournament_repeat_guests`.`parent_id` AS `add_tournament_repeat_guests___parent_id_raw`, `add_tournament_repeat_guests_0`.`userID` AS `add_tournament_repeat_guests___userID_raw`, `#__users`.`id` AS `add_tournament_repeat_guests___userID`, `add_tournament_repeat_guests`.`guests` AS `add_tournament_repeat_guests___guests`, `add_tournament_repeat_guests`.`guests` AS `add_tournament_repeat_guests___guests_raw`, `add_tournament_repeat_guests`.`params` AS `add_tournament_repeat_guests___params`, `add_tournament_repeat_guests`.`params` AS `add_tournament_repeat_guests___params_raw`, `add_tournament_repeat_guests_0`.`add_guests` AS `add_tournament_repeat_guests___add_guests_raw`, `#__users_0`.`name` AS `add_tournament_repeat_guests___add_guests`, `add_tournament`.`id` AS slug , `add_tournament`.`id` AS `__pk_val` FROM `add_tournament` LEFT JOIN `#__jem_venues` AS `#__jem_venues` ON `#__jem_venues`.`id` = `add_tournament`.`collectiontype` LEFT JOIN `select_game` AS `select_game` ON `select_game`.`collectiontype` = `add_tournament`.`cityID` LEFT JOIN `#__jem_events` AS `#__jem_events` ON `#__jem_events`.`id` = `add_tournament`.`eventID` LEFT JOIN `select_game` AS `select_game_0` ON `select_game_0`.`collectiontype` = `add_tournament`.`stateID` LEFT JOIN `#__jem_events` AS `#__jem_events_0` ON `#__jem_events_0`.`id` = `add_tournament`.`eventID` LEFT JOIN `add_tournament_repeat_guests` AS `add_tournament_repeat_guests_0` ON `add_tournament_repeat_guests_0`.`parent_id` = `add_tournament`.`id` LEFT JOIN `#__users` AS `#__users` ON `#__users`.`id` = `add_tournament_repeat_guests_0`.`userID` LEFT JOIN `#__users` AS `#__users_0` ON `#__users_0`.`id` = `add_tournament_repeat_guests_0`.`add_guests` ORDER BY `add_tournament`.`event_start` DESC,`add_tournament`.`event_start` DESC</pre>
 
Hmmm, weird. Never seen that happen before.

I'm going to have to install Akeeba, grab a backup and instal it here, look at the code.

-- hugh
 
I went back, deleted all the repeat-guest joins, tables, groups and remade them all, but as soon as I create the join to the parent table I get the same error
 
Went through and trashed all relationships/joins across the board and seemed to have cleared the problem, looks like I'm back on track now
 
OK, good. I'm pretty sure the problem was that at some point our join metadata table had gotten messed up. This is something that happens occasionally (very infrequently) when you do a lot of moving elements between groups, or moving groups between forms, changing joins on lists, etc. It seems to be something that usually happens when people are learning Fabrik, and making lots of changes trying to figure things out. And I've never been able to duplicate it.

My advice when learning Fabrik is to have a sandbox to play in just play in and get the concepts straight and your design worked out, which you can trash if it gets it's undies in a bundle.

Plus of course run Akeeba and automatic back ups daily, and manually before you make any big sweeping changes.

-- hugh
 
BTW, I was unable to run an Akeeba backup on your site. It got wedged backing up the images folder, seemingly backing up massive files, and the failed archive was about 28GB. So I deleted it. :)

-- hugh
 
Yeah I have a global catalog of every arcade machine ever made on the site with 5 images for every game so it's heavy.

Easy question - how do I get the repeat guest group to show it's Name/Label in the form I added it to? No matter what I do all it seems to want to display is the table name. not it's label

Harder question - Repeat guests are populating properly to the child table along with the events themselves being logged in the parent table in MYSQL so that's all good. However, I have a list pointed at the parent event table which shows all the events created. For every repeat guest added in the form, another copy of the event shows in the Fabrik list when there should be just one entry.

Images attached.

add_tournament.JPG
Capture.JPG
 
Can you post a pic of the easy one? I'm not sure what you mean. The group will (should) always show the label.

For the row thing - that's the expected behavior. Remember that a repeat group is a one-to-many join. So if you have (say) 3 repeats, then when doing the query ...

SELECT * FROM parent LEFT JOIN child ON parent.id = child.parent_id

... you get three rows in the result set, with the same column data from 'parent', and the 3 different sets of column data from the 'child'.

1,1
1,2
1,3

By default, we represent this as three rows in the list.

If you go to the Joins tab in the List's Data settings, you'll find an option for how to represent your joins - either as each row separately, or merged, or merged & reduced.

Choosing merge will represent those three rows as one row, with the data from each 0f the repeated columns merged into a single cell.

1, [1,2,3]

Merge & reduce is sometimes needed if you have more than one repeat join. If you have (say) 3 child1 repeats and 2 child2 repeats, you'll get six rows in the result set, with six of the parent, 3 of child1, each with two child2.

1,1,1
1,1,2
1,2,1
1,2,2
1,3,1
1,3,2

If you only merge, you get ...

1,[1,1,2,2,3,3],[1,2,1,2,1,2]

By also "reducing" the data you take out the duplicated child data.

1,[1,2,3],[1,2]

-- hugh
 
Thanks for the explanation on that, I will go and play with those settings.

Screenshot attached for the repeat group label issue, I'm trying to stop that showing up in the middle of my form.
 

Attachments

  • Capture.JPG
    Capture.JPG
    97.6 KB · Views: 92
We are in need of some funding.
More details.

Thank you.

Members online

No members online now.
Back
Top