Hello,
I have been trawling the internet for a tutorial or any help on using the multi save function within the DB Save action.
Can anyone point me in the right direction? Or help me on how to use it? I want to save mulitple records to a table basically.
Also on another note - I am using the chronoconnect to edit the records but on save instead of going back to the chrono list of records I would like it stay on the form(edit) page, is that possible?
Thanks in advance for any help.
Regards
Mark
Hi Mark,
In order to save multiple records, the data must be under a model id, you must enable this setting in the db save settings.
Your fields names may need to be in this format:
Model[0][field]
Model[1][field]
This would save 2 records!
Regarding the second question, the save action redirects you to the list, so I don't think its possible to stay on the form page.
Regards,
Max
Max, ChronoForms developer
ChronoMyAdmin: Database administration within Joomla, no phpMyAdmin needed.
ChronoMails simplifies Joomla email: newsletters, logging, and custom templates.
Hi Mark,
Or, to put it another way, you'd need to use a Custom Link from CC to the form to avoid being redirected back to CC.
Bob
Hello guys.
Thanks for your help.
I was trying the Field name format already and it wasn't working (only submitting the second fields data) but I have come in this morning tried it again and it works! Great.
Regarding the custom link Idea bob, can you point me in the right direction on how to set that up please?
Thanks again.
Regards
Mark
Hi Mark,
When I have done this I've just built a standard <a> link in the Body section of a Custom listing. In CFv5 I think you could do it in a standard Table listing building the link in the HTML box on the Settings tab. The link need to got to a form event with a record identifier so that you can retrieve the record in the form using a DB Load action.
Bob
Ok Bob, thanks.
I think I understand what you mean. I need to use a DB read within the form rather than using CC to load records. I will then need to post an identifier in the custom link so that the DB read knows which records to load.
I will give this a go and post again if I think it is the right solution for my needs.
I am still testing the saving of multiple records as well as this seem to work pretty sporadically. It still sometimes only posts the second of two records rather than posting both of them.
I will post my findings as soon as I can.
Thanks for your help,
Regards
Mark
Hi Mark,
If you are comfortable with coding then you can try the following code to get things working quickly using CF:
<?php
//generate a new model
\GCore\Libs\GModel::generateModel('mymodel', array(
'tablename' => '#__my_table',
));
$mymodel = '\GCore\Models\mymodel';
//find multiple records
$mymodel::getInstance()->find('all', array('conditions' => array()));
//find first record
$mymodel::getInstance()->find('first', array('conditions' => array()));
//save multiple records
$mymodel::getInstance()->saveAll($data);
Max, ChronoForms developer
ChronoMyAdmin: Database administration within Joomla, no phpMyAdmin needed.
ChronoMails simplifies Joomla email: newsletters, logging, and custom templates.
Thanks Max,
I will give that a go if I need it. I think I may have got around it. As it is a large form we might have multiple submits throughout.
I think the issue is when we are saving lots of things at once to multiple tables for some reason.
It is now working pretty good. I have used a custom link from CC to edit the form and used DB reads to get the records I need. This allows me to stay on the page after submit.
So the issues are pretty much solved for now - thanks for the help.
I have sent a message in to get the patch which fixes the file upload not working if the first file value is empty - so just waiting for that to come through.
Thanks again.
Regards
Mark