Hidden Field value don't show up on Data Listing and Database

bryancd911 08 Jan, 2015
I've tried to develop a form that computes (thanks for the tutorials) the total no. of days between 2 dates. I used this code on Submit event:

<?php
$date_from = $form->data['pickup_date'];
$date_to   = $form->data['dropoff_date'];
$date_from = strtotime($date_from);
$date_to   = strtotime($date_to);
$days = abs($date_to - $date_from);
$days = $days/(60*60*24);
$form->data['total_days'] = $days;
?>


Almost everything works perfect except for one thing - my hidden field which is named as total_days doesn't display the value on the data listing and database. I used a debugger to figure out whats wrong but the odd thing is that, it displays the value of the total_days.

Can someone please tell and assiste me, why the value of my total_days (which is perfectly computed and displayed on a debugger) can't be recorded and displayed on my data listing and database.

Thanks in advance!!!
GreyHead 09 Jan, 2015
Answer
1 Likes
Hi bryancd911,

I'm sorry but I don't understand exactly what the problem is. If the value is being shown correctly in the debugger, then it is in the $form->data array. It can then be included in a DB Save and/or Email action - provided that they are *after* the Custom Code action where you calculate the value.

The hidden input is not used if it is in the On Load event as the value isn't calculated until the form is submitted.

Bob
bryancd911 09 Jan, 2015
PERFECT!!! You never fail to amaze me Bob!!!

I've just drag the Custom Codes above the DB Save. Thanks a lot!!!
This topic is locked and no more replies can be posted.