I'm using MODX 2.4.2 and I have a multi-page FormIt-form. In this form the user has the possibility to choose from different radio-boxes. Depending on the choice the user made the selection gets valued. Those values need to get calculated/summated together, to receive a total value, which will be used for further calculating.
So far I have a snippet/hook "calculating" like this:
<?php
$age = $hook->getValue('age');
if($age === '40') { $result = '111'; }
if($age === '50') { $result = '222'; }
if($married === 'yes') { $result = $result + '333'; }
if($married === 'no') { $result = $result + '444'; }
$hook->setValue('all', $result);
return true;
The hook gets called in the FormIt-snippet-call (having a typo in it leads the form to an error, so the hooks implemented).
[[!FormIt?
&hooks=`spam,calculating,email,redirect`
&redirectTo=`36`
&validate=`age:required, married:required,`
&emailTpl=`Step1`
&emailTo=`[email protected]`
&emailSubject=`new message`
&store=`1`
]]
So imagine the user did choose the age "40" and that he is married. This should result in 111 + 333 = 444, but I'm just getting the placeholder [[+all]] displayed in the email i'm getting sent via FormIt.
Even without the calcultion part I'm just getting the blank placeholder [[+all]]:
<?php
$age = $hook->getValue('age');
if($age === '40') { $result = '111'; }
if($age === '50') { $result = '222'; }
$hook->setValue('all', $result);
return true;
What is going wrong here, any help will be appreciated.
EDIT: adding some form-code:
<form action="[[~[[*id]]]]" method="post" class="form">
<input type="hidden" name="nospam:blank" value="[[+fi.nospam]]" />
<span>1. Age</span><br />
<input type="radio" name="age[]" value="40" [[!+fi.age:FormItIsChecked=`40`]]" />> 40 years
<input type="radio" name="age[]" value="50" [[!+fi.age:FormItIsChecked=`50`]]" />> 50 years
<input type="radio" name="age[]" value="60" [[!+fi.age:FormItIsChecked=`60`]]" />> 60 years
<input type="radio" name="age[]" value="70" [[!+fi.age:FormItIsChecked=`70`]]" />> 70 years
<input type="radio" name="age[]" value="80" [[!+fi.age:FormItIsChecked=`80`]]" />> 80 years
<br /><br />
<span>2. Married</span><br />
<input type="radio" name="married[]" value="yes" [[!+fi.married:FormItIsChecked=`yes`]]" />yes
<input type="radio" name="married[]" value="no" [[!+fi.married:FormItIsChecked=`50no]]" />no
<br /> <br />
<input class="button" type="submit" value="Weiter" />
</form>