[[!FormIt? &hooks=`email,redirect` &emailTpl=`contactus.tpl` &emailFrom=`[email protected]` &emailFromName=`domain.org.uk Customer Enquiry` &emailTo=`[email protected],[[+addressTo]]` &emailSubject=`domain.org.uk Customer Enquiry` &emailReplyTo=`[[+email]]` &validate=`name:required, email:email:required, message:required:stripTags, tel:isNumber` &validationErrorMessage=`Please review the form for the following errors: [[+errors]]` &submitVar=`contact-form` &redirectTo=`29` ]]
<option value="[email protected]" [[!+fi.addressTo:FormItIsSelected=`[email protected]`]]>option 1</option>
This question has been answered by johnnyp. See the first response.
&emailTo=`[email protected],[[+addressTo]]` // if [[+addressTo]] has no content elsewhere on the page, it will always be empty
[[!FormIt? &emailTo=`[[+addressTo]]` ]] ... <select name="addressTo"> <option value="[email protected]" [[!+fi.addressTo:FormItIsSelected=`[email protected]`]]>Admin Pro</option> <option value="[email protected]" [[!+fi.addressTo:FormItIsSelected=`[email protected]`]]>Huncho Head</option> </select>
[[+errors]]
Please review the form for the following errors: [[!+fi.error_message]]
[[!+fi.error.name]]
[2014-02-28 16:45:05] (ERROR @ /home/sites/domain.org.uk/public_html/core/cache/includes/elements/modsnippet/5.include.cache.php : 39) PHP warning: in_array() expects parameter 2 to be array, string given [2014-02-28 16:45:05] (ERROR @ /home/sites/domain.org.uk/public_html/core/cache/includes/elements/modsnippet/5.include.cache.php : 39) PHP warning: in_array() expects parameter 2 to be array, string given [2014-02-28 16:45:08] (ERROR @ /home/sites/domain.org.uk/public_html/core/cache/includes/elements/modsnippet/5.include.cache.php : 39) PHP warning: in_array() expects parameter 2 to be array, null given [2014-02-28 16:45:08] (ERROR @ /home/sites/domain.org.uk/public_html/core/cache/includes/elements/modsnippet/5.include.cache.php : 39) PHP warning: in_array() expects parameter 2 to be array, null given
<?php
function elements_modsnippet_5($scriptProperties= array()) {
global $modx;
if (is_array($scriptProperties)) {
extract($scriptProperties, EXTR_SKIP);
}
/**
* FormIt
*
* Copyright 2009-2012 by Shaun McCormick <[email protected]>
*
* FormIt is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License as published by the Free
* Software Foundation; either version 2 of the License, or (at your option) any
* later version.
*
* FormIt is distributed in the hope that it will be useful, but WITHOUT ANY
* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
* A PARTICULAR PURPOSE. See the GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along with
* FormIt; if not, write to the Free Software Foundation, Inc., 59 Temple Place,
* Suite 330, Boston, MA 02111-1307 USA
*
* @package formit
*/
/**
* Custom output filter that returns checked="checked" if the value is set
*
* @var string $input
* @var string $options
* @package formit
*/
$output = ' ';
if ($input == $options) {
$output = ' selected="selected"';
}
$input = $modx->fromJSON($input);
if (in_array($options,$input)) {
$output = ' selected="selected"';
}
return $output;
}
value="[[+addressTo]]"
<form action="[[~[[*id]]]]" method="post">
<fieldset>
<select name="addressTo" required="">
<option value="" disabled selected>Subject of Enquiry</option>
<option value="[email protected]" [[!+fi.addressTo:FormItIsSelected=`[email protected]`]]>1</option>
<option value="[email protected]" [[!+fi.addressTo:FormItIsSelected=`[email protected]`]]>2</option>
</select>
<label for="name" >Your Name</label>
<input id="name" name="name" value="[[!+fi.name]]" placeholder="Your Name"><span class="error">[[!+fi.error.name]]</span>
<label for="email" >Your Email</label>
<input id="email" name="email" type="email" value="[[!+fi.email]]" placeholder="Your Email Address"><span class="error">[[!+fi.error.email]]</span>
<label for="tel" >Your Phone Number</label>
<input id="tel" name="tel" type="tel" value="[[!+fi.tel]]" placeholder="Your Phone Number"><span class="error">[[!+fi.error.tel]]</span>
<label for="message" >Your Message</label>
<textarea id="message" name="message" type="text" value="[[!+fi.message]]" maxlength="500" title="" placeholder="Your Message"></textarea><span class="error">[[!+fi.error.message]]</span>
<input name="contact-form" type="submit" value="Send">
</fieldset>
</form>