[Solved] Multi page and cf_id

vales 13 Jan, 2011
I found this code in the book "ChronoForms 3.1 for Joomla! Site Cookbook". I tried a form multi-page in to html code the next form, or in submit code after saving the previous form in the db but I get this error.
code
$Myform =& CFChronoForm::getInstance();
$data= $MyForm->tablerow['jos_chronoforms_atto_10'];


error

Notice: Undefined index: jos_chronoforms_atto_10 in C:\wamp\www\joomlafree\components\com_chronocontact\libraries\customcode.php(64) : eval()'d code on line 3



What is the problem ?
GreyHead 14 Jan, 2011
Hi vales,

You have $Myform in the first row and $MyForm in the second. Otherwise the code looks OK to me.

Bob
vales 14 Jan, 2011
Thanks Bob, but that's not the problem.

This is the code
$MyForm =& CFChronoForm::getInstance();
$idatto= $MyForm->tablerow['jos_chronoforms_atto_10'];
$idallegato= $MyForm->tablerow['jos_chronoforms_allegati_10'];


and the image is that of errors.
GreyHead 14 Jan, 2011
Hi vales,

In your first post the code is running in the OnSubmit Before Email box; normally this is executed before the data is saved to the database so there is no record to check.

In the second post the code is running I think in the Form HTML of a later step. That should be OK.

Please add this debug line and see what information you get from it:
$MyForm =& CFChronoForm::getInstance();
$mainframe->enqueuemessage('$MyForm: '.print_r($MyForm, true));


You will get a *lot* of data in a system message when you show the form. Please copy and paste it here.

Bob
vales 14 Jan, 2011
This the system message

# $MyForm: CFChronoForm Object ( [formrow] => stdClass Object ( [id] => 6 [name] => madre_atto_10 [html] => [scriptcode] => [stylecode] => [redirecturl] => [emailresults] => 2 [fieldsnames] => [fieldstypes] => [onsubmitcode] => [onsubmitcodeb4] =>
Atto e allegati caricati correttamente
 
 
[server_validation] => [attformtag] => [submiturl] => [emailtemplate] => [useremailtemplate] => [paramsall] => formmethod=post LoadFiles=No submissions_limit= submissions_limit_error=Sorry but you can not submit the form again very soon like this! handlepostedarrays=Yes debug=0 checkToken=1 mysql_type=1 enmambots=No captcha_dataload=0 captcha_dataload_skip= useCurrent= datefieldformat=d/m/Y datefieldsnames= datefieldextras=classes: ['dashboard'] dbconnection=Yes savedataorder=after_email dvfields=recordtime dvrecord=Record #n uploads=No uploadfields= uploadpath=/membri/valesweb/components/com_chronocontact/uploads/madre_atto_10/ filename_format=$filename = date('YmdHis').'_'.$chronofile['name']; upload_exceedslimit=Sorry, Your uploaded file size exceeds the allowed limit. upload_lesslimit=Sorry, Your uploaded file size is less than the allowed limit upload_notallowed=Sorry, Your uploaded file type is not allowed imagever=No imtype=0 imgver_error_msg=You have entered an incorrect verification code at the bottom of the form. validate=No validatetype=mootools validate_onlyOnBlur=1 validate_wait= validate_onlyOnSubmit=0 validation_type=default val_required= val_validate_number= val_validate_digits= val_validate_alpha= val_validate_alphanum= val_validate_date= val_validate_email= val_validate_url= val_validate_date_au= val_validate_currency_dollar= val_validate_selection= val_validate_one_required= val_validate_confirmation= servervalidate=Yes autogenerated_order=3 onsubmitcode_order=2 plugins_order=1 plugins=cf_multi_page mplugins_order=9 tablenames=jos_chronoforms_albo_log,jos_chronoforms_allegati_10,jos_chronoforms_atto_10 [titlesall] => [extravalrules] => [dbclasses] => [autogenerated] => formparams("dbconnection") == "Yes"){ $user = JFactory::getUser(); $row =& JTable::getInstance("chronoforms_albo_log", "Table"); srand((double)microtime()*10000); $inum = "I" . substr(base64_encode(md5(rand())), 0, 16).md5(uniqid(mt_rand(), true)); JRequest::setVar( "recordtime", JRequest::getVar( "recordtime", date("Y-m-d")." - ".date("H:i:s"), "post", "string", "" )); JRequest::setVar( "ipaddress", JRequest::getVar( "ipaddress", $_SERVER["REMOTE_ADDR"], "post", "string", "" )); JRequest::setVar( "uid", JRequest::getVar( "uid", $inum, "post", "string", "" )); JRequest::setVar( "cf_user_id", JRequest::getVar( "cf_user_id", $user->id, "post", "int", "" )); $post = JRequest::get( "post" , JREQUEST_ALLOWRAW ); if (!$row->bind( $post )) { JError::raiseWarning(100, $row->getError()); } if (!$row->store()) { JError::raiseWarning(100, $row->getError()); } $MyForm->tablerow["jos_chronoforms_albo_log"] = $row; } ?> formparams("dbconnection") == "Yes"){ $user = JFactory::getUser(); $row =& JTable::getInstance("chronoforms_allegati_10", "Table"); srand((double)microtime()*10000); $inum = "I" . substr(base64_encode(md5(rand())), 0, 16).md5(uniqid(mt_rand(), true)); JRequest::setVar( "recordtime", JRequest::getVar( "recordtime", date("Y-m-d")." - ".date("H:i:s"), "post", "string", "" )); JRequest::setVar( "ipaddress", JRequest::getVar( "ipaddress", $_SERVER["REMOTE_ADDR"], "post", "string", "" )); JRequest::setVar( "uid", JRequest::getVar( "uid", $inum, "post", "string", "" )); JRequest::setVar( "cf_user_id", JRequest::getVar( "cf_user_id", $user->id, "post", "int", "" )); $post = JRequest::get( "post" , JREQUEST_ALLOWRAW ); if (!$row->bind( $post )) { JError::raiseWarning(100, $row->getError()); } if (!$row->store()) { JError::raiseWarning(100, $row->getError()); } $MyForm->tablerow["jos_chronoforms_allegati_10"] = $row; } ?> formparams("dbconnection") == "Yes"){ $user = JFactory::getUser(); $row =& JTable::getInstance("chronoforms_atto_10", "Table"); srand((double)microtime()*10000); $inum = "I" . substr(base64_encode(md5(rand())), 0, 16).md5(uniqid(mt_rand(), true)); JRequest::setVar( "recordtime", JRequest::getVar( "recordtime", date("Y-m-d")." - ".date("H:i:s"), "post", "string", "" )); JRequest::setVar( "ipaddress", JRequest::getVar( "ipaddress", $_SERVER["REMOTE_ADDR"], "post", "string", "" )); JRequest::setVar( "uid", JRequest::getVar( "uid", $inum, "post", "string", "" )); JRequest::setVar( "cf_user_id", JRequest::getVar( "cf_user_id", $user->id, "post", "int", "" )); $post = JRequest::get( "post" , JREQUEST_ALLOWRAW ); if (!$row->bind( $post )) { JError::raiseWarning(100, $row->getError()); } if (!$row->store()) { JError::raiseWarning(100, $row->getError()); } $MyForm->tablerow["jos_chronoforms_atto_10"] = $row; } ?> [chronocode] => [theme] => default [published] => 1 [extra1] => [extra2] => [extra3] => [extra4] => [extra5] => ) [formparams] => JParameter Object ( [_raw] => formmethod=post LoadFiles=No submissions_limit= submissions_limit_error=Sorry but you can not submit the form again very soon like this! handlepostedarrays=Yes debug=0 checkToken=1 mysql_type=1 enmambots=No captcha_dataload=0 captcha_dataload_skip= useCurrent= datefieldformat=d/m/Y datefieldsnames= datefieldextras=classes: ['dashboard'] dbconnection=Yes savedataorder=after_email dvfields=recordtime dvrecord=Record #n uploads=No uploadfields= uploadpath=/membri/valesweb/components/com_chronocontact/uploads/madre_atto_10/ filename_format=$filename = date('YmdHis').'_'.$chronofile['name']; upload_exceedslimit=Sorry, Your uploaded file size exceeds the allowed limit. upload_lesslimit=Sorry, Your uploaded file size is less than the allowed limit upload_notallowed=Sorry, Your uploaded file type is not allowed imagever=No imtype=0 imgver_error_msg=You have entered an incorrect verification code at the bottom of the form. validate=No validatetype=mootools validate_onlyOnBlur=1 validate_wait= validate_onlyOnSubmit=0 validation_type=default val_required= val_validate_number= val_validate_digits= val_validate_alpha= val_validate_alphanum= val_validate_date= val_validate_email= val_validate_url= val_validate_date_au= val_validate_currency_dollar= val_validate_selection= val_validate_one_required= val_validate_confirmation= servervalidate=Yes autogenerated_order=3 onsubmitcode_order=2 plugins_order=1 plugins=cf_multi_page mplugins_order=9 tablenames=jos_chronoforms_albo_log,jos_chronoforms_allegati_10,jos_chronoforms_atto_10 [_xml] => [_elements] => Array ( ) [_elementPath] => Array ( [0] => /home/ugdv6o5h/domains/vales.joomlafree.it/public_html/libraries/joomla/html/parameter/element ) [_defaultNameSpace] => _default [_registry] => Array ( [_default] => Array ( [data] => stdClass Object ( [formmethod] => post [LoadFiles] => No [submissions_limit] => [submissions_limit_error] => Sorry but you can not submit the form again very soon like this! [handlepostedarrays] => Yes [debug] => 0 [checkToken] => 1 [mysql_type] => 1 [enmambots] => No [captcha_dataload] => 0 [captcha_dataload_skip] => [useCurrent] => [datefieldformat] => d/m/Y [datefieldsnames] => [datefieldextras] => classes: ['dashboard'] [dbconnection] => Yes [savedataorder] => after_email [dvfields] => recordtime [dvrecord] => Record #n [uploads] => No [uploadfields] => [uploadpath] => /membri/valesweb/components/com_chronocontact/uploads/madre_atto_10/ [filename_format] => $filename = date('YmdHis').'_'.$chronofile['name']; [upload_exceedslimit] => Sorry, Your uploaded file size exceeds the allowed limit. [upload_lesslimit] => Sorry, Your uploaded file size is less than the allowed limit [upload_notallowed] => Sorry, Your uploaded file type is not allowed [imagever] => No [imtype] => 0 [imgver_error_msg] => You have entered an incorrect verification code at the bottom of the form. [validate] => No [validatetype] => mootools [validate_onlyOnBlur] => 1 [validate_wait] => [validate_onlyOnSubmit] => 0 [validation_type] => default [val_required] => [val_validate_number] => [val_validate_digits] => [val_validate_alpha] => [val_validate_alphanum] => [val_validate_date] => [val_validate_email] => [val_validate_url] => [val_validate_date_au] => [val_validate_currency_dollar] => [val_validate_selection] => [val_validate_one_required] => [val_validate_confirmation] => [servervalidate] => Yes [autogenerated_order] => 3 [onsubmitcode_order] => 2 [plugins_order] => 1 [plugins] => cf_multi_page [mplugins_order] => 9 [tablenames] => jos_chronoforms_albo_log,jos_chronoforms_allegati_10,jos_chronoforms_atto_10 ) ) ) [_errors] => Array ( ) ) [formerrors] => [formdebug] =>
# Form passed first SPAM check OK
# Form passed the submissions limit (if enabled) OK
# Form passed the Image verification (if enabled) OK
# Form passed the server side validation (if enabled) OK
# $_POST Array: Array ( [datainizio_atto] => 2011-01-14 [datafine_atto] => 2011-02-13 [data_atto] => 2011-01-13 [sezione] => sezione 1 [categoria] => categoria 1 sez 1 [anno] => 0 [titolo_all] => 1r [cod_atto] => [atto_cf_id] => [numero_albo] => 0 [button_3] => Invia [cfformstep] => 1 [1ca9895a13ba41ff622179c5290a1472] => 1 [1cf1] => c8f31fa12d3661730ccecac83082e357 [chronoformname] => madre_atto_10 )
# $_FILES Array: Array ( [allegato] => Array ( [name] => form_manager.png [type] => image/png [tmp_name] => /tmp/phpjBXHOA [error] => 0 [size] => 6383 ) )
[error_found] => [stoprunning] => [haltFunction] => Array ( [emails] => [uploads] => [plugins_before_email] => [plugins_after_email] => [autogenerated_before_email] => [autogenerated_after_email] => [onsubmitcode] => [onsubmitcodeb4] => ) [tablerow] => Array ( ) [posted] => Array ( [datainizio_atto] => 2011-01-14 [datafine_atto] => 2011-02-13 [data_atto] => 2011-01-13 [sezione] => sezione 1 [categoria] => categoria 1 sez 1 [anno] => 0 [titolo_all] => 1r [cod_atto] => [atto_cf_id] => [numero_albo] => 0 [button_3] => Invia [cfformstep] => 1 [1ca9895a13ba41ff622179c5290a1472] => 1 [1cf1] => c8f31fa12d3661730ccecac83082e357 [chronoformname] => madre_atto_10 ) [pagetype] => chronocontact [formname] => ChronoContact_madre_atto_10 [stoploading] => [submission_complete] => [_errors] => Array ( ) ) 


In the first attempt in onsumit code I had changed the order in Run order setting as in the image.

In the second attempt the code is in the form at later step in HTML code.
GreyHead 14 Jan, 2011
Hi Vales,

Thanks very much. Helpful but I'm still not completely clear what is happening.

How do you have these forms set up? This is the mother form detial I think and includes the Autogenerated code for the three database saves. If I remember correctly the mother form DB Connection doesn't run until after the last form step. This would fit with the error messages that you are seeing.

Have you checked to see that data is being saved after the intermediate steps?

Bob
vales 14 Jan, 2011
This is a form of Multi Page 3 steps.

Mother form madre_atto_10
son 1 form atto_10
son 2 form allegati_10
son 3 form allegati_10_conferma

The Form mother and son 2 had 3 tables in the database connection.
Is it possible that the problem is the 3 tables in the connection?

I tried another multipage form with multiple tables and the problem is the same.
GreyHead 14 Jan, 2011
Hi vales,

I don't think that the three connections is causing the problem. I'll build a set of test form when I have a moment and see if I can work it out.

Bob
vales 14 Jan, 2011
I finally found the solution.
It is enter the name of the previous form (allegati_10) in which it was made the save on database, so:

$MyForm =& CFChronoForm::getInstance('allegati_10');
$idatto= $MyForm->tablerow['jos_chronoforms_atto_10'];
$idallegato= $MyForm->tablerow['jos_chronoforms_allegati_10'];


Now all is fine.

Tanks Bob.
GreyHead 15 Jan, 2011
Hi vales,

Excellent. I should have thought of that.

Bob
vales 15 Jan, 2011
But this does not work again in the field Email OnSubmit Before box, with the setting of the database before the email.

But for the moment the solution in the next form is good.
GreyHead 16 Jan, 2011
Hi vales,

Code in the OnSubmit Before box is only executed if 'Send Emails' is set to 'Yes' on the form General tab. Could this be what is blocking the execution here?

Bob
vales 16 Jan, 2011
Yes Bob, Send email is set to "Yes" and the form return the same error.
vales 19 Jan, 2011
Bad news. It seems that not all versions of PHP support the code.

php 5.2.0 yes
php 5.2.13 yes
php 5.2.8 not

This results in some tests. 😢
GreyHead 19 Jan, 2011
Hi vales,

It's a bit odd that it would run in 2.0 and 2.13 but not in 2.8 What error message do you see?

Bob
vales 19 Jan, 2011
Finally resolved. The problem was in my code. Why do I use the code in this self-installing application.
http://www.chronoengine.com/forums/index.php?option=com_chronoforums&cont=posts&f=7&t=18878
It is installed as a standard component for Joomla.
The forms are contained in the file install.sql. Which is a dump of database tables with some modifications for automatic installation at each site.
The bug was that in some fields (paramsall, dbclasses, autogenerated) form of the tables had the prefix #__ instead of the joomla site.

I remember that is inserted in the name of the form previous (allegati_10) in which it was made the save on database, so:

$MyForm =& CFChronoForm::getInstance('allegati_10');



Thanks to Bob for the information that allowed me to find the bug.
GreyHead 19 Jan, 2011
Hi vales,

I'm glad you found the problem.

The #__ prefix is standard Joomla! - the database classes will replace this with whatever is set as the table prefix for the site. 99% of the time this is jos_ but not always.

Bob
This topic is locked and no more replies can be posted.