<?php
$send = $hook->getValue('sendToMeToo');
if ($send == 1)
{
$userChoice = $hook->getValue('usremail');
$choice = intval($userChoice); // convert string in integer
$hook->setValue('emailAddress',$group[$choice]);
}
[[!FormIt?
&hooks=`SendCc,spam,email,FormitSuccess`
&emailTpl=`sentEmailTpl`
&emailTo=`[[+emailToSomeone]]`
&emailCC=`[[+emailAddress]]`
&emailFrom=`[email protected]`
&emailMultiSeparator=`<br />`
&submitVar=`submit`
&validate=`usremail:email:required,
emailToSomeone:email:required,
yourMessage:required
&errTpl=`<p class="error"><strong>[[+error]]</strong></p>`
]]
<form id="contactForm" action="[[~[[*id]]]]#contactForm" method="POST">
[[+success]]
<label for="emailToSomeone">E-mail to</label>
<input type="text" name="emailToSomeone" id="emailToSomeone" placeholder="E-mail to" value="[[!+fi.emailToSomeone]]">
[[+fi.error.emailToSomeone]]
<label for="yourMessage">Your Message</label>
<textarea name="yourMessage" placeholder="what do you want to say">[[!+fi.yourMessage]]</textarea>
[[!+fi.error.yourMessage]]
<label for="usremail">Tvůj e-mail</label>
<input type="email" name="usremail" id="usremail" value="[[!+fi.usremail]]" placeholder="Your Email">
[[+fi.error.usremail]]
<input type="checkbox" name="sendToMeToo" id="sendToMeToo" value="0" [!+fi.sendToMeToo:FormItIsChecked=`1`]] />
<label for="sendToMeToo">Send me the copy of the form.</label>
<input name="submit" type="submit" value="Send" />
</form>
This question has been answered by fbasta. See the first response.
[[!+fi.sendToMeToo:notempty=`&emailCC=`[[+emailAddress]]`]]
<input type="checkbox" name="sendToMeToo" id="sendToMeToo" value="0" [!+fi.sendToMeToo:FormItIsChecked=`1`]] />
[[!+fi.sendToMeToo:FormItIsChecked=`1`]]
[[!FormIt?
&hooks=`spam,email,FormitSuccess`
&emailTpl=`sentEmailTpl`
&emailTo=`[[+emailToSomeone]]`
[[!+fi.sendToMeToo:notempty=`&emailCC=`[[+emailAddress]]`]]
&emailFrom=`[email protected]`
&emailMultiSeparator=`<br />`
&submitVar=`submit`
&validate=`usremail:email:required,
emailToSomeone:email:required,
yourMessage:required
&errTpl=`<p class="error"><strong>[[+error]]</strong></p>`
]]
&emailCC=[[!+fi.sendToMeToo:notempty=`[[+emailAddress]]`]]
