Forums

How do you do a dynamicto in V6?

jgarvas 02 Mar, 2019
In previous versions of ChronoForms you could make a form with a radio list or a pull down that let the user pick a recipient by department or some other name and then in custom code you could define what the email address was.

Then in the email block you would set the "DynamicTo" to say email_to_use (based on the code below). But when I look at all of the options in an Email node in V6 there is no such thing as a DynamicTo.

How is this done in V6 now?

The custom code looked like this assuming in the form you populated 'recipient' with the selected radio button or option list value:

$recipient = JRequest::getString('recipient', '', 'post');
$emails = array('dept1'=>'joe@here.org',
'dept2'=>'mary@here.org',
'dept3'=>'jan@here.org'');

$form->data['email_to_use'] = $emails[$recipient];

$desttype = array('dept1'=>' Sales Question',
'dept2'=>'Refund Request',
'dept3'=>'Technical Request');

$dest = $desttype[$recipient];

$fname = JRequest::getString('fname', '', 'post');
$lname = JRequest::getString('lname', '', 'post');
$fullname = $fname.' '.$lname;
$form->data['fullname'] = $fullname;

$subject = JRequest::getString('subject', '', 'post');
$subject = '[PrefixText] ('.$dest.') '.$subject;
$form->data['subject'] = $subject;

jgarvas 02 Mar, 2019
Are you saying I put that in the normal To: field? Is my custom code properly processing the form data? Because this isn't working for me.
healyhatman 02 Mar, 2019
You put that in your normal To: field. Or at least you would if your input field was returning an email instead of a department reference.

None of your custom code will be working, you need to use $this->data("field") it's a function now not an array reference.

To SET a variable to use later you can use $this->set("variablename", $value) and retrieve it for use in your subject or To: field with {var:variablename}

I don't think you need to use JRequest::getString(.....) just use $this->data("fieldname")

So should be for example
$emails = ["dept1" => "jo@here.org", "dep2" => etc etc];
$this->set("email_to_use", $emails[$this->data("recipient")]);
Then in your to: you use {var:email_to_use}

There's a manual and a bunch of demo forms and a series of FAQs you can read through.
This topic is locked and no more replies can be posted.