id);$contact_me = JRequest::getString('contact_me', '', 'post');if ( $contact_me == "yes" ) { $MyFormEmails->setEmailData('contact', 'enabled', true); $MyFormEmails->setEmailData('nocontact','enabled',true);}?>"> Custom Code Documentation - Forums

Forums

Custom Code Documentation

whycali 09 Jan, 2012
I have the book, and used the formula for sending different e-mails based on a form field. I'm getting an error, "Class 'CFEMails' not found." Then I've searched for any documentation on classes available in chronoforms custom code and came up empty handed.

Can someone please point me toward documentation?

thanks!

Here's the code I used:

<?php
$MyFormEmails =& CFEMails::getInstance($MyForm->formrow->id);
$contact_me = JRequest::getString('contact_me', '', 'post');
if ( $contact_me == "yes" ) {
  $MyFormEmails->setEmailData('contact', 'enabled', true);
  $MyFormEmails->setEmailData('nocontact','enabled',true);
}
?>
GreyHead 10 Jan, 2012
Hi whycali,

It sounds as though you may be using ChronoForms v4; the code in the book is for ChronoForms v3. Is that correct?

Bob
whycali 10 Jan, 2012
Yes, that's correct. I'm running on Joomla! 1.7, but plan to upgrade to 2.5 soon.
GreyHead 10 Jan, 2012
Hi whycali ,

The simplest answer is probably to get my Email [GH] action which includes a Conditional box that will only send the email if a test on the form data is passed.

NB In CFv4 RC3,0 there is an Install actions button on the toolbar.

Bob
whycali 10 Jan, 2012
thanks for the quick reply and code, that worked wonderfully. I did notice an Event Switcher custom action. Can you please send me some sample code to set this up? thanks!

Mike
GreyHead 10 Jan, 2012
Hi whycall,

There's a post about the Event Switcher here you probably don't need it if there is a simple go/no-go choice about sending an email (though you could use it for that).

Bob
whycali 10 Jan, 2012
Ideally, we'd send an email AND show html based on the answer to a question. It's pretty simple, actually, the form asks if they'd like us to contact them. If they say yes, then we add the line, "We'll contact you in the next 48 hours." to the reply e-mail. It would also make sense to add that line to the response HTML.

I'll take a look at that link, thanks!

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