-
- 143 Posts
Hi,
I am trying to change a formit parameter based on a checkbox selection, is this something I need a custom hook to do?
[[!FormIt? &hooks=`successMessage,spam,mChimpXSubscribe`
&validate=`email:email:required`
&mcApiKey=`123`
&mcListId=`[[!+fi.list]]`
&mcFailOnApiKey=`1`
&mcDoubleOptin =`0`
&mcFailOnListNotExists=`1`
&mcFailOnMissingRequired=`1`
&mcFailOnNotSubscribed=`1`
&successMessage=`Subscription successful, thank you`
&mcFailOnAlreadySubscribed=`1`
]]
<form action="[[~[[*id]]]]" method="post" id="mailingList">
<input type="hidden" name="nospam:blank" value="" />
<input type="text" class="[[!+fi.error.email:notempty=`fieldError`]]" name="email" id="email" value="[[+fi.email:default=`[email protected]`]]"/>
<select name="list">
<option value="123455666" [[!+fi.list:FormItIsSelected=`123455666`]]>trade</option>
<option value="123455646" [[!+fi.list:FormItIsSelected=`123455646`]]>not trade</option>
</select>
<input type="submit" class="submit" value="Join" />
</form>
<p class="formStatus">
[[!+fi.addressTo]]
[[!+fi.error.email]]
[[!+fi.error_message:notempty=`[[!+fi.error_message]]`]]
[[!+fi.successMessage:notempty=`[[!+fi.successMessage]]`]]
</p>
[ed. note: eighthday last edited this post 10 years, 10 months ago.]
Yes, you'll need to do that in a hook. [[!+fi.list]] is parsed before the outer [[!FormIt]] call is.
If I remember correctly, you can use something along these lines in a hook:
$value = $hook->getValue('foobar');
if ($value == 'baz') {
$hook->formit->config['mcListId'] = $value;
}