[SOLVED] Calc Element | Erratic Calculation with custom bootstrap form template + SOLUTION

Context :
I have created 3 custom form detail templates based on the excellent Rob Clayburn vimeo tutorial

The issue with a calc element is the only custom form detail template related issue I add.

I can display, save, retrieve all my form data without any problem.

Issue :
1. Calc element was working fine and the correct value was rendered correctly in the detail form template.
for example: displayed calculated value was "11:00"
2. Displayed calculated value wasn't saved in the database.
for example: saved value was "15:00" instead of "11:00"

Wrapping the calc field :
1. I tried to wrap my calc field on several ways (see #11 and #13), but no success here.
But wrapping doesn't seem to be necessary for all field types. I only add an issue with a Picklist which needed to be wrapped.

Solution :
Form PHP Plugin

Since the problem occurred while saving the form, I decided to save the calc element value through the php plugin, I'm already using to save all my custom form detail template data.

I added the following lines of code :

Code:
// Training endtime
$trainingendtime=$data['fab_booking___book_landingtime'];
$trainingendtime = is_array($trainingendtime) ? $trainingendtime[0] : $trainingendtime;

Code:
// Update training endtime
$query = $db->getQuery(true);
$query = "UPDATE fab_booking SET book_landingtime = '$trainingendtime' WHERE id = '$bookingid'";
$db->setQuery($query);
$trip=$db->execute();

Result :
Now the calculated value is saved|retrieved into|from my database table field correctly.

http://www.screencast.com/t/HzA9LQgI6u

Comment :
I haven't found an alternative to the PHP plugin to save the data of my custom form detail templates.
It is certainly not the state of the art, but all my custom form detail templates are working fine now.
If someone knows how to save the data from a custom form detail template into the database, please share the solution.
 
We are in need of some funding.
More details.

Thank you.

Members online

Back
Top