Forums

Summing for fields, no result

fribse 10 Sep, 2012
Hi Guys

Well, the chronoforms is being used by me a lot on this website, it's working great.
I'm creating a new form, where I have 4 fields that needs to be summed, and emailed.
But for some reason I can't make it work, I've looked up previous threads, but I don't get a result.
The four fields are defined as 'number'
The Custom Code I've put in the 'on submit' action looks like this:
<?php
$number1 = JRequest::getInt('daser1', 0, 'post');
$number2 = JRequest::getInt('daser2', 0, 'post');
$number3 = JRequest::getInt('daser3', 0, 'post');
$number4 = JRequest::getInt('daser4', 0, 'post');
$from->data['daser'] = $number1 + $number2 + $number3 + $number4 ;
?>

The four input fields are called daser1 .. daser4, and I've defined a hidden field called daser, that stores the result for the email.

But when I send the mail, the daser field is empty.

What did I do wrong?
fribse 10 Sep, 2012
Ahh, never mind, found another example in the forum, way simpler, and it worked :-)
<?php
$form->data['daser'] = $form->data['daser1'] + $form->data['daser2'] + $form->data['daser3'] + $form->data['daser4'];
?>
GreyHead 10 Sep, 2012
Hi fribse,

The code using JRequest will work with CFv3 but not CFv4 - for that you need the $form->data version.

Bob
This topic is locked and no more replies can be posted.

VPS & Email Hosting 20% discount
hostinger