[[!FormIt? &hooks=`email` &emailSubject=`Getting my checkbox to work` &emailCC=`[[!+fi.cc:is=`on`:then=`[[+yourEmail]]`]] ` &validate=`yourEmail:email:required` ]] <form action="[[~[[*id]]]]" method="post"> <input type="text" id="yourEmail" name="yourEmail"> <input type="checkbox" name="cc" id="cc"> <button>Let's do this!</button> </form>
This question has been answered by sjeijk. See the first response.
<!-- This would also work --> <option value="yellow" [[!+fi.color:is=`yellow`:then=`selected`]]>Yellow</option>
<?php
$cc = $hook->getValue('cc');
if (!$cc) {
$email = "";
} else {
$email = $hook->getValue('yourEmail');
}
$hook->setValue('emailCC', $email);
return true;
[[!FormIt?
&hooks=`checkboxCC,email`
&emailSubject=`Getting my checkbox to work`
&emailCC=`[[+emailCC]]`
&validate=`yourEmail:email:required`
]]
<form action="[[~[[*id]]]]" method="post">
<input type="text" id="yourEmail" name="yourEmail">
<input type="checkbox" name="cc" id="cc">
<button>Let's do this!</button>
</form>