I have a form which uses a repeater area to display items with a checkbox next to each item. called book_it. When the checkbox is ticked, I want only the selected items to save.
Here is part of the array returned when I click submit if only the first item is checked:
On the submit event, I have a loop - loop_event67 with the data source of {data:assets} and in the body of the loop I have an event switcher which has a data provider of {var:loop_event67.row.book_it}
The Events I set up are 1,0 to match the values of the checkbox for book_it
In event 1 I have put the Save Data expecting it to only run when the item is checked and book_it is equal to 1
But when I select the checkbox for the first item - as above then all of the items are saved
If I select the last item then only the last item is saved as I expected
Can anyone help me understand what I'm doing wrong here please - or maybe suggest a better way to go about it?
Many thanks
Here is part of the array returned when I click submit if only the first item is checked:
[assets] => Array ( [99] => Array ( [book_it] => 1 [delivery] => Yes [dropcrate_id] => OhBot crate 1 [description] => Dropcrate of 15 blue OhBots ) [100] => Array ( [description] => Dropcrate of 15 blue OhBots ) [101] => Array ( [description] => Dropcrate of 15 blue OhBots ) )
On the submit event, I have a loop - loop_event67 with the data source of {data:assets} and in the body of the loop I have an event switcher which has a data provider of {var:loop_event67.row.book_it}
The Events I set up are 1,0 to match the values of the checkbox for book_it
In event 1 I have put the Save Data expecting it to only run when the item is checked and book_it is equal to 1
But when I select the checkbox for the first item - as above then all of the items are saved
If I select the last item then only the last item is saved as I expected
Can anyone help me understand what I'm doing wrong here please - or maybe suggest a better way to go about it?
Many thanks
Disable the save data action, and in the loop event body put {debug:loop_event67.row} and you should see the structure of each iteration.
Thanks - here is the debug. Both of the debugs are the same on both iterations.
My data source for the loop is {data:assets} - I was expecting it to look at that array and then loop on the elements inside, so first [83] and then [84], like it does int he example in the manual but that doesn't seem to be happening.
I'm sure I've missed something fundamental here, but the more I stare at it the more I can't see it.
debug loop event start
My data source for the loop is {data:assets} - I was expecting it to look at that array and then loop on the elements inside, so first [83] and then [84], like it does int he example in the manual but that doesn't seem to be happening.
I'm sure I've missed something fundamental here, but the more I stare at it the more I can't see it.
debug loop event start
Array ( [option] => com_chronoforms6 [cont] => manager [chronoform] => Booking1-0 [event] => submit [start_date] => 2018-09-20 [end_date] => 2018-09-21 [assets] => Array ( [83] => Array ( [book_it] => 1 [delivery] => No [dropcrate_id] => iPad1 [description] => Dropcrate of 14 iPads ) [84] => Array ( [description] => Dropcrate of 14 iPads ) ) [location] => Ribston [Start_date] => [End_date] => [button78] => [cookieAcceptanceCookie] => accepted [__atuvc] => 4|29,0|30,1|31 [cfac6951893bdd7d18b2bc234b98e90c] => 5374d3c1e7d1df06b997a814c43f75dd [65d2c9358065e947a77e674ebbe3f65f] => 9730a40e0fb635ae2ea6fa297abcae11 [joomla_user_state] => logged_in )
Array ( [validate_fields2] => Array ( [log] => Automatic validation enabled. [var] => 1 ) )debug loop event end
Array ( [option] => com_chronoforms6 [cont] => manager [chronoform] => Booking1-0 [event] => submit [start_date] => 2018-09-20 [end_date] => 2018-09-21 [assets] => Array ( [83] => Array ( [book_it] => 1 [delivery] => No [dropcrate_id] => iPad1 [description] => Dropcrate of 14 iPads ) [84] => Array ( [description] => Dropcrate of 14 iPads ) ) [location] => Ribston [Start_date] => [End_date] => [button78] => [cookieAcceptanceCookie] => accepted [__atuvc] => 4|29,0|30,1|31 [cfac6951893bdd7d18b2bc234b98e90c] => 5374d3c1e7d1df06b997a814c43f75dd [65d2c9358065e947a77e674ebbe3f65f] => 9730a40e0fb635ae2ea6fa297abcae11 [joomla_user_state] => logged_in )
Array ( [validate_fields2] => Array ( [log] => Automatic validation enabled. [var] => 1 ) )debug loop event start
Array ( [option] => com_chronoforms6 [cont] => manager [chronoform] => Booking1-0 [event] => submit [start_date] => 2018-09-20 [end_date] => 2018-09-21 [assets] => Array ( [83] => Array ( [book_it] => 1 [delivery] => No [dropcrate_id] => iPad1 [description] => Dropcrate of 14 iPads ) [84] => Array ( [description] => Dropcrate of 14 iPads ) ) [location] => Ribston [Start_date] => [End_date] => [button78] => [cookieAcceptanceCookie] => accepted [__atuvc] => 4|29,0|30,1|31 [cfac6951893bdd7d18b2bc234b98e90c] => 5374d3c1e7d1df06b997a814c43f75dd [65d2c9358065e947a77e674ebbe3f65f] => 9730a40e0fb635ae2ea6fa297abcae11 [joomla_user_state] => logged_in )
Array ( [validate_fields2] => Array ( [log] => Automatic validation enabled. [var] => 1 ) [save_data12] => Array ( [data] => Array ( [book_it] => 1 [delivery] => No [dropcrate_id] => iPad1 [description] => Dropcrate of 14 iPads [created] => 2018-09-05 05:07:41 [user_id] => 225 [asset_id] => 83 [start_date] => 2018-09-20 [end_date] => 2018-09-21 [request_delivery] => No [location] => Ribston ) [_success] => Data saved successfully [log] => Array ( [0] => INSERT INTO `k5jm3_tblbookings` (`created`, `user_id`, `asset_id`, `start_date`, `end_date`, `request_delivery`, `location`) values ('2018-09-05 05:07:41', '225', '83', '2018-09-20', '2018-09-21', 'No', 'Ribston'); ) [var] => Array ( [created] => 2018-09-05 05:07:41 [user_id] => 225 [asset_id] => 83 [start_date] => 2018-09-20 [end_date] => 2018-09-21 [request_delivery] => No [location] => Ribston [id] => 412 ) ) [email8] => Array ( [recipients] => Array ( [0] => mst@rribstonhall.gloucs.sch.uk [1] => bookings@cyberhub.uk [2] => mikkistorey@hotmail.com ) [subject] => Your Dropcrate booking details [body] => <p>Hi Super User.</p> <p>Below is a record of your booking details.</p> <p>The asset should be available from the collection date - but please contact the school before making the trip over if you are collecting it yourself.</p> <p>You can also view or delete this booking by logging into the website and going to the dropcrates page.</p> Asset ID: <br> Dropcrate ID:<br> Form fields below:<br> <table width="100%" cellpadding="5" cellspacing="3" border="0" class="ui table"><tr><td width="30%" valign="top" align="right"><strong>location</strong></td><td width="70%" valign="top" align="left">Ribston</td></tr><tr><td width="30%" valign="top" align="right"><strong>start_date</strong></td><td width="70%" valign="top" align="left">2018-09-20</td></tr><tr><td width="30%" valign="top" align="right"><strong>end_date</strong></td><td width="70%" valign="top" align="left">2018-09-21</td></tr><tr><td width="30%" valign="top" align="right"><strong>assets[83][dropcrate_id]</strong></td><td width="70%" valign="top" align="left">iPad1</td></tr><tr><td width="30%" valign="top" align="right"><strong>assets[83][description]</strong></td><td width="70%" valign="top" align="left">Dropcrate of 14 iPads</td></tr><tr><td width="30%" valign="top" align="right"><strong>assets[84][description]</strong></td><td width="70%" valign="top" align="left">Dropcrate of 14 iPads</td></tr><tr><td width="30%" valign="top" align="right"><strong>Book Asset?</strong></td><td width="70%" valign="top" align="left">{"book_it":"1","delivery":"No","dropcrate_id":"iPad1","description":"Dropcrate of 14 iPads"}</td></tr><tr><td width="30%" valign="top" align="right"><strong>Book Asset?</strong></td><td width="70%" valign="top" align="left">{"description":"Dropcrate of 14 iPads"}</td></tr></table> <p><b>Please do not reply to this email as we do not monitor the email account</b></p> [from_name] => Cyberhub Bookings [from_email] => bookings@cyberhub.uk [reply_name] => Cyberhub Bookings [reply_email] => bookings@cyberhub.uk [result] => the Mail sent successfully. [var] => 1 ) )debug loop event end
Array ( [option] => com_chronoforms6 [cont] => manager [chronoform] => Booking1-0 [event] => submit [start_date] => 2018-09-20 [end_date] => 2018-09-21 [assets] => Array ( [83] => Array ( [book_it] => 1 [delivery] => No [dropcrate_id] => iPad1 [description] => Dropcrate of 14 iPads ) [84] => Array ( [description] => Dropcrate of 14 iPads ) ) [location] => Ribston [Start_date] => [End_date] => [button78] => [cookieAcceptanceCookie] => accepted [__atuvc] => 4|29,0|30,1|31 [cfac6951893bdd7d18b2bc234b98e90c] => 5374d3c1e7d1df06b997a814c43f75dd [65d2c9358065e947a77e674ebbe3f65f] => 9730a40e0fb635ae2ea6fa297abcae11 [joomla_user_state] => logged_in )
Array ( [validate_fields2] => Array ( [log] => Automatic validation enabled. [var] => 1 )
Try just {var:loop_event67.row} in the body, that debug code wasn't right (showing you everything each time which is not helpful).
That helps. Here is what I get:
debug loop event start
{"book_it":"1","delivery":"Yes","dropcrate_id":"iPad1","description":"Dropcrate of 14 iPads"}
debug loop event end
debug loop event start{"book_it":"0","description":"Dropcrate of 14 iPads"}
debug loop event end
So on the first iteration, book_it is 1 and I would expect the event switcher to see that and run the save event. On the second iteration, book_it is 0 so I expected it to run the 0 block in the event switcher,
Is there a problem with the event switcher?

Or the save data?
debug loop event start
{"book_it":"1","delivery":"Yes","dropcrate_id":"iPad1","description":"Dropcrate of 14 iPads"}
debug loop event end
debug loop event start{"book_it":"0","description":"Dropcrate of 14 iPads"}
debug loop event end
So on the first iteration, book_it is 1 and I would expect the event switcher to see that and run the save event. On the second iteration, book_it is 0 so I expected it to run the 0 block in the event switcher,
Is there a problem with the event switcher?
Or the save data?
This topic is locked and no more replies can be posted.