• Hello Fabrik Community

    Fabrik is now in the hands of the development team that brought you Fabrik for Joomla 4. We have recently transitioned the Fabrik site over to a new server and are busy trying to clean it up. We have upgraded the site to Joomla 4 and are running the latest version of Fabrik 4. We have also upgraded the Xenforo forum software to the latest version. Many of the widgets you might have been used to on the forum are no longer operational, many abandoned by the developers. We hope to bring back some of the important ones as we have time.

    Exciting times to be sure.

    The Fabrik 4.0 Official release is now available. In addition, the Fabrik codebase is now available in a public repository. See the notices about these in the announcements section

    We wish to shout out a very big Thank You to all of you who have made donations. They have really helped. But we can always use more...wink..wink..

    Also a big Thank You to those of you who have been assisting others in the forum. This takes a very big burden off of us as we work on bugs, the website and the future of Fabrik.

Onload calculation element not calculating on child groups

Geoff Cloake

New Member
Hi there,

Here's my scenario:-
1. First i create 2 list, one is the timesheet and the other is tasks
7us1dFd.png

2. Secondly, i created 2 Groups - Tasks & Tasks - [aa_acc_time_sheet]
onvR2H9.png

3. Next, i created 2 elements - one is the billable_time for Tasks-[aa_cc_time_sheet] and the other to do the calculation of converting time (hh:mm) to decimal which is time_billing_calc for Tasks - [aa_cc_time_sheet].
8cWrijs.png


4. The time element is relatively straight forward with the default settings with only the formatting as such:
RFTbhRU.png

5. The calculation element settings are as such:-
A53HZsU.png


And this is the weird part, if you point this element to the main group then you will not have issue its being calculated onload HOWEVER if these elements are pointed to the sub-groups / a child group then the onload will not display the minutes and rather just the hours but if you save it, you'll get the correct decimal point.

My questions is why is the onload calculation is not working on a sub-group form?
hi5PqdT.png



Any help is will be very much appreciated.
Thank you.
 
OK, looks like this is one of those issues where the data format during rendering is different to when submitting. So the value of the time element can either be a string, 04:15, or an array(04, 15), like during AJAX updating. Also, because it might be an array, you can't use a placeholder, so just access the data array directly.

Code:
$myTime = $data['fab_repeat_test_17_repeat___the_time_raw'];
if (!empty($myTime)) {
  if (!is_array($myTime)) {
   $myTime = explode(':', $myTime);
  }
  dump($myTime, 'mytime');
  $decTime = ((int)$myTime[0]*60) + (int)$myTime[1];
  return round($decTime/60, 2);
}
return 0;

The above code worked in my test setup. Replace the element name accordingly (make sure you append _raw to it).

Also, you'll need to add {fab_repeat_test_17_repeat___the_time_raw} (well, your name) to the "AJAX Observe fields", as you no longer have the placeholder in the code for us to automagically use.

Note, this took me about 45 minutes to set up, test and figure out. That's pretty much it for standard support for the month. If you have more of these corner case, custom code type issues, you'll need to get a Pro sub.

-- hugh
 
We are in need of some funding.
More details.

Thank you.

Members online

Back
Top