Forums

Problem with Dynamic To and not required email fields

fabaya 28 Jul, 2010
I have made a recomendator form with DYNAMIC TO like this:

Your name:

Your email:

Friend 1 name: name1 required
Friend 1 email: email1 required

Friend 2 name: name2 optional
Friend 2 email: email2 optional

Friend 3 name: name3 optional
Friend 3 email: email3 optional

First mail, obiusly get delivered

But If the User send only 1 recommendation in the confirmation messages I get 2
error messages LIKE this...

You must provide at least one recipient e-mail address
You must provide at least one recipient e-mail address

And this error message can confuse the user about the proper delivery of his recommendation

Put dummy emails boxes like default values in the 2 optional fields dont fix the problem, because the phpmail send me an undelivered message for every single recommendation in my email box.

There is another solution for this problem?

Thanks a lot
GreyHead 01 Aug, 2010
Hi fabaya,

The solution to this is to set the second and third emails to 'disabled' in the Email Setup box. Then enable them in the OnSubmti Before box if there are emails submitted.
<?php
$MyFormEmails =& CFEMails::getInstance($MyForm->formrow->id);
$email2 = JRequest::getString('email2', '', 'post');
if ( $email2 ) {
  $MyFormEmails->setEmailData(2, 'enabled', true);
}
$email3 = JRequest::getString('email3', '', 'post');
if ( $email3 ) {
  $MyFormEmails->setEmailData(3, 'enabled', true);
}
?>


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