Here’s a scenario you could try. Instead of using the &thankyou parameter use the &eformOnValidate event and the &eFormOnBeforeFormMerge event to do the following.
In the eFormOnValidate event function you can check if there are any validation errors, if so just let eForm handle things as usual. If the form validates run your calculation and then set a dummy error in the $vMsg array. This will cause eForm to think there’s an error and so display the form again. However you don’t want an
error message to appear so, in the eFormOnBeforeFormMerge event function you check if the special dummy error is set by checking the $fields[’validationmessage’]. If so you delete the $fields[’validationmessage’] and let eForm display the form. (Sadly you can’t check the $vMsg array directly as it is not available in this event function)
<?php
function onValidateFunction(&$fields,&$vMsg,&$rMsg){
if( count($vMsg)+count($rMsg)>0 ) return true; //let eForm handle true errors
$rMsg[] = 'myDummyFlag'; //force an erorr...
calcMe(&$fields); //call original calculation function
return true;
}
?>
<?php
function onBeforeFormMergeFunction(&$fields){
if(strstr($fields['validationmessage'],'myDummyFlag')
unset($fields['validationmessage']);
return true;
}
?>
You will of course need to place a place holder for your calculation results in the form template itself. This may mean that you have to include a whole paragraph in the placeholder value. You can in fact put that in a separate chunk and load that in your ’calcMe’ function
<?php
function calcMe(&$fields){
//do calculation
$fields['result'] = $fields['a'] * $fields['b'];
//load template
$result_template = efLoadTemplate('chunkName');
$fields['result_message'] = formMerge($result_template,$fields);
//
return;
}
?>
example result chunk:
<p>The result of [+a+] times [+b+] is [+$result+].</p>
<p>Feel free to try again</p>
Doing things this way does mean that the form will never officially validate and never reach any thank you page, but in your case that doesn’t matter I suspect.