Hey Guy's,
I am getting in a bit deeper with a profile/user account page and the client now wants a editable form that pulls from two (or more) database tables. I thought about doing a tabbed form, but the client wants just one page.
Is it possible to save to multiple tables from one form?
Thanks for the help,
I am getting in a bit deeper with a profile/user account page and the client now wants a editable form that pulls from two (or more) database tables. I thought about doing a tabbed form, but the client wants just one page.
Is it possible to save to multiple tables from one form?
Thanks for the help,
Hi samoht,
Yes no problem - except that you have to hand-code one of the saves. ChronoForms built-in code will only save to one table. Just add the code to do the other one in the OnSubmit box.
Bob
Yes no problem - except that you have to hand-code one of the saves. ChronoForms built-in code will only save to one table. Just add the code to do the other one in the OnSubmit box.
Bob
Awesome, Thanks Bob!
I assume that I will have to use Joomla code to do this save?
Can you show me an example of calling the table and using an "UPDATE" sql ??
Thanks agian!
I assume that I will have to use Joomla code to do this save?
Can you show me an example of calling the table and using an "UPDATE" sql ??
Thanks agian!
Hi samoht,
indeed you can save to 2 tables using the DB connection tab, you can multi select more than 1 table, but you can't use one field as a relation to another field in the other table, I guess that's why Bob has suggested doing the 2nd one with a SQL
Regards
Max
indeed you can save to 2 tables using the DB connection tab, you can multi select more than 1 table, but you can't use one field as a relation to another field in the other table, I guess that's why Bob has suggested doing the 2nd one with a SQL
Regards
Max
Hi Max and samoht,
To tell the truth I didn't know that you could connect to more than one table - something new I learned today.
Bob
To tell the truth I didn't know that you could connect to more than one table - something new I learned today.
Bob
Hi Bob,
No problems, but as I said, they will be 2 completely unrelated records which I think may not be whats needed in this case!😉
Regards,
Max
No problems, but as I said, they will be 2 completely unrelated records which I think may not be whats needed in this case!😉
Regards,
Max
I have the same problem (post "1 form, 2 tables").
If I use "ChronoForms Autogenerated Code" to save data in the first table, what code add in the "OnSubmit box" to save data in the other table?
Bob tell me to use a global variable called "$row_chronocontact_form_name" to read the id of the first record but I don´t know how.
Can you give me an example?
If I use "ChronoForms Autogenerated Code" to save data in the first table, what code add in the "OnSubmit box" to save data in the other table?
Bob tell me to use a global variable called "$row_chronocontact_form_name" to read the id of the first record but I don´t know how.
Can you give me an example?
Hi samoht & vsbr,
I think it goes like this.
Connect the main table to your form using DB Connection.
Use the Form Order tab to run OnSubmit After *after* the AutoGenerated Code
In the OnSubmit After box you'll need something like this:
Bob
I think it goes like this.
Connect the main table to your form using DB Connection.
Use the Form Order tab to run OnSubmit After *after* the AutoGenerated Code
In the OnSubmit After box you'll need something like this:
<?php
global $row_chronocontact_form_name;
$cf_id = $row_chronocontact_form_name->cf_id;
$db =& JFactory::getDBO();
$query = "
UPDATE `#__some_table`
SET `field_name` = 'value',
. . .
WHERE `cf_id` = $cf_id;";
$db->setQuery($query);
$db->query();
?>
Not complete, not tested and will need debugging!Bob
Thanks! This problem is solved.
Just change:
$cf_id = $row_chronocontact_form_name->cf_id;
Just change:
$cf_id = $row_chronocontact_form_name->cf_id;
Thanks a lot!
I am close, but I now have a weird problem with the user email returning a bunch of javascript??
When I just use the user object and:
the result is :
<script language='JavaScript' type='text/javascript'> <!-- var prefix = 'ma' + 'il' + 'to'; var path = 'hr' + 'ef' + '='; var addy65893 = 'reformedstudent' + '@'; addy65893 = addy65893 + 'gmail' + '.' + 'com'; document.write( '<a ' + path + '\'' + prefix + ':' + addy65893 + '\'>' ); document.write( addy65893 ); document.write( '<\/a>' ); //-->\n </script><script language='JavaScript' type='text/javascript'> <!-- document.write( '<span style=\'display: none;\'>' ); //--> </script>This e-mail address is being protected from spambots. You need JavaScript enabled to view it <script language='JavaScript' type='text/javascript'> <!-- document.write( '</' ); document.write( 'span>' ); //--> </script>
Any idea how to strip this so I just get the email address?
Thanks
I am close, but I now have a weird problem with the user email returning a bunch of javascript??
When I just use the user object and:
<?php echo $user->get('email');?>
the result is :
<script language='JavaScript' type='text/javascript'> <!-- var prefix = 'ma' + 'il' + 'to'; var path = 'hr' + 'ef' + '='; var addy65893 = 'reformedstudent' + '@'; addy65893 = addy65893 + 'gmail' + '.' + 'com'; document.write( '<a ' + path + '\'' + prefix + ':' + addy65893 + '\'>' ); document.write( addy65893 ); document.write( '<\/a>' ); //-->\n </script><script language='JavaScript' type='text/javascript'> <!-- document.write( '<span style=\'display: none;\'>' ); //--> </script>This e-mail address is being protected from spambots. You need JavaScript enabled to view it <script language='JavaScript' type='text/javascript'> <!-- document.write( '</' ); document.write( 'span>' ); //--> </script>
Any idea how to strip this so I just get the email address?
Thanks
Hi samoht,
You have the Joomla Email Cloaking PlugIn enabled. Go to the PlugIn manager and swap over the order of the ChronoForms and Email Cloaking PlugIns.
Bob
You have the Joomla Email Cloaking PlugIn enabled. Go to the PlugIn manager and swap over the order of the ChronoForms and Email Cloaking PlugIns.
Bob
Thanks again Bob!
Another quick question though,
you posted:
I should be able to use {mytextboxid} as the 'value' correct?
or am I using the $_POST array?
Another quick question though,
you posted:
UPDATE `#__some_table`
SET `field_name` = 'value',
. . .
WHERE `cf_id` = $cf_id;";
I should be able to use {mytextboxid} as the 'value' correct?
or am I using the $_POST array?
Hi samoht,
I think you can use {mytextboxid} OK - try it and see.
But personally I prefer to use JRequest::getInt('mytextboxid', '', 'post') so that I know exactly what data I am getting.
Bob
I think you can use {mytextboxid} OK - try it and see.
But personally I prefer to use JRequest::getInt('mytextboxid', '', 'post') so that I know exactly what data I am getting.
Bob
Bob,
I might have been misleading - would you use the JRequest for every value that you're updating?
?? this does not seem right?
I might have been misleading - would you use the JRequest for every value that you're updating?
UPDATE `#__some_table`
SET `name` = JRequest::getInt('name', '', 'post'),`title` = JRequest::getInt('title', '', 'post'),
. . .
WHERE `cf_id` = $cf_id;";
?? this does not seem right?
Hi samoht,
Yes you can, that's how the old version of ChronoForms used to do it.
Bob
PS I'd probably get the whole post array and validate selected fields but basically the same.
Yes you can, that's how the old version of ChronoForms used to do it.
Bob
PS I'd probably get the whole post array and validate selected fields but basically the same.
Bob,
Quick question about the field names from the main table and the $_POST names:
do they need to match?
(ie. username is the field name so do I need $_POST['username'])
because currently I named my inputs things like "uname" and "pword" for username and password - but I am afraid these wont work?
Quick question about the field names from the main table and the $_POST names:
do they need to match?
(ie. username is the field name so do I need $_POST['username'])
because currently I named my inputs things like "uname" and "pword" for username and password - but I am afraid these wont work?
URRR!
so what I have in the onSubmit after is:
this brings up an empty print_r ??
So obviously nothing is getting updated on the tables
Help
so what I have in the onSubmit after is:
<?php
global $row_chronocontact_myProfile;
//uncomment below to see all the reg values from the form printed to screen.
echo "cf_returning_values: ".print_r($row_chronocontact_myProfile, true)."<br /><br />";
echo '<div class="key_page">';
$smuser = $row_chronocontact_myProfile->id;
$strLogin = $row_chronocontact_myProfile->username;
$strPassword = $row_chronocontact_myProfile->password_clear;
//key re-gen stuff
$db =& JFactory::getDBO();
$query = '
UPDATE `#__vm_product_license`
SET `license_start` = "'.time().'", `key_code` = JRequest::getInt("lkey", "", "post")
WHERE `user_id` = $smuser';
$db->setQuery($query);
$db->query();
//second update
$query ='
UPDATE `#__users`
SET
`username` = JRequest::getInt("uname", "", "post"),
`password` = JRequest::getInt("pword", "", "post"),
`email` = JRequest::getInt("email", "", "post")
WHERE `id` = $smuser;';
$db->setQuery($query);
$db->query();
?>
this brings up an empty print_r ??
So obviously nothing is getting updated on the tables
Help
Hi samoht,
Have you used the Run Order tab to have OnSubmit After run *after* the AutoGenerated Code?
Bob
Have you used the Run Order tab to have OnSubmit After run *after* the AutoGenerated Code?
Bob
yes, here is what I have for the run order:
autogenerated block = 2
on submit block = 3
plugins block = 1
autogenerated block = 2
on submit block = 3
plugins block = 1
Hi samoht,
Please take a look in the AutoGenerated Code tab window and you should see a statement lik global $row_chronocontact_myProfile; near the end. Is this identical to the one you have used?
Bob
Please take a look in the AutoGenerated Code tab window and you should see a statement lik global $row_chronocontact_myProfile; near the end. Is this identical to the one you have used?
Bob
Hi Bob,
No, the were not identical. So I changed the onsubmit to match the auto gen which is
global $row_jos_vm_user_info;
then I just added a
but nothing shows up?
Isn't this var supposed to have everything from the form?
No, the were not identical. So I changed the onsubmit to match the auto gen which is
global $row_jos_vm_user_info;
then I just added a
echo "cf_info: ".print_r($row_jos_vm_user_info, true)."<br /><br />";
but nothing shows up?
Isn't this var supposed to have everything from the form?
This topic is locked and no more replies can be posted.