Forums

undefined method CFCustomCode::showFormErrors()

lighthunter 22 Jan, 2010
Hello,

ChronoForms_V3.1_RC5.5
There's Form Code, onSubmit Events Code, before sending email:
I want replace empty values after submit form. Without this code emails sends OK.

<?php
$MyForm = $this->getInstance('Form_Rejestracyjny');
$MyFormEmails =& CFEMails::getInstance($MyForm->formrow->id);

for($i=0;$i<count($MyFormEmails->emails);$i++){
$MyFormEmails->emails[$i]->template = str_replace("{check2}", "", $MyFormEmails->emails[$i]->template);
$MyFormEmails->emails[$i]->template = str_replace("{check3}", "", $MyFormEmails->emails[$i]->template);
$MyFormEmails->emails[$i]->template = str_replace("{check4}", "", $MyFormEmails->emails[$i]->template);
$MyFormEmails->emails[$i]->template = str_replace("{check5}", "", $MyFormEmails->emails[$i]->template);
$MyFormEmails->emails[$i]->template = str_replace("{check6}", "", $MyFormEmails->emails[$i]->template);
$MyFormEmails->emails[$i]->template = str_replace("{check7}", "", $MyFormEmails->emails[$i]->template);
$MyFormEmails->emails[$i]->template = str_replace("{check8}", "", $MyFormEmails->emails[$i]->template);
}
?>


When I run the form, I get error
Fatal error: Call to undefined method CFCustomCode::showFormErrors() in public_html/components/com_chronocontact/libraries/chronoform.php on line 427
nml375 22 Jan, 2010
Hi,
Please change the definition of MyForm as follows:
<?php
/* This will not work, $this refers to the CFCustomCode class, not the CFChronoForm class */
$MyForm =& $this->getInstance('Form_Rejestrancyjny');

/* Make sure we use the proper method from the proper class instead: */
$MyForm =& CFChronoForm::getInstance('Form_Rejestrancyjny');
...


/Fredrik
GreyHead 23 Jan, 2010
Hi Fredrik & lighthunter.

It's worth checking with a print_r debug statement if $MyForm is already defined and available, in my experiments it quite often is.

Bob
lighthunter 24 Jan, 2010

Hi,
Please change the definition of MyForm as follows:
/Fredrik



It's works. Thanx a lot
This topic is locked and no more replies can be posted.