1. Fabrik 3.8 has been released. As usual, we strongly recommend that you backup your site (using Akeeba) before upgrading. Report any issues in the forums, we will answer promptly.

calc field after update 3.8

Discussion in 'Community' started by merlino68, Oct 13, 2017 at 1:56 PM.

  1. merlino68

    merlino68 Member

    Level: Supporter
    j.8 fabrik 3.8
    after updating my calculation to calculate age does not work anymore.
    the field is white
    this is the calc :
    $date= '{Anagrafica___Data_Nascita}';
    $date = strtotime($date);
    $now = time();
    $diff = $now - $date;
    $years = floor($diff / 31556926);
    return $years;

    thanks
     
  2. merlino68

    merlino68 Member

    Level: Supporter
    upload_2017-10-13_16-11-25.png
    I try a test , when this option is "NO" the field is blank , if YES I see the values in the field but no re-calculation in the table
     
  3. troester

    troester Well-Known Member Staff Member

    Level: Standard
    In your calc you are using $date= '{Anagrafica___Data_Nascita}';
    but you are watching {tm_anagrafica_clienti___data_nascita}
    So what is your correct element name?
    Did you try {your-element_raw}?
     
  4. merlino68

    merlino68 Member

    Level: Supporter
    Sorry ......, this is my calc

    $date= '{tm_anagrafica_clienti___data_nascita}';
    $date = strtotime($date);
    $now = time();
    $diff = $now - $date;
    $years = floor($diff / 31556926);
    return $years;

    I try {tm_anagrafica_clienti___data_nascita_raw}
    but it does not work

    thanks
     
  5. 7webcreator

    7webcreator Member

    Level: Standard
    Hello,
    I have also the same issue. All my calc elements do not display in list view since my update to Fabrik 3.8. The value of the calc element is visible in form view.

    My calculation:
    return (float)'{pagamenti___quota_asso_raw}' + (float)'{pagamenti___pacchetto_raw}' - (float)'{pagamenti___sconto_raw}' + (float)'{pagamenti___lez_aggiunt_raw}';

    My Joomla version is 3.8.1. But I got the problem before I updated Joomla.

    Any ideas why?
    Thank you
     
  6. cheesegrits

    cheesegrits Support Gopher Staff Member

    Level: Community
    The only way to debug calc code is to install jdump:

    https://github.com/mathiasverraes/jdump/downloads

    ... and put debug statement in the code so you can see what your various variables and placeholders are set to. Like ...

    Code (Text):

    dump('{pagamenti___quota_asso_raw}', "some meaningful comment so you know what this should be");
    dump('{pagamenti___pacchetto_raw}', "pagamenti___pacchetto_raw");
     
    When you load the page, jdump will open a popup (so you'll probably have to tell your browser to allow it) with information for each dump() line you put in.

    -- hugh
     
  7. merlino68

    merlino68 Member

    Level: Supporter
    I try with _raw and without _raw this the log
    the element name is correct.......maybe is the format date ?
    upload_2017-10-13_21-40-46.png
     
  8. troester

    troester Well-Known Member Staff Member

    Level: Standard
    I just tried with your code:
    It's empty in list view - if you don't return a string!
    So
    return (string)$years;
    is doing.
    Which may also solve @7webcreator ?

    It seems something has become more sensitive about variable types.
     
  9. merlino68

    merlino68 Member

    Level: Supporter
    Yes, now it works for me
    thank you very much:D:D
     
  10. cheesegrits

    cheesegrits Support Gopher Staff Member

    Level: Community
    Ah, interesting. Yes, that was from a commit I did a few months ago, working on speeding up list rendering. Turns out we can save a lot of time (like seconds) on big lists with lots of elements, that don't have tooltips, if we don't try and load the tooltip layout if the tooltip text is empty. Anyway, side effect of that was not showing non-string data.

    Should be fixed as of:

    https://github.com/Fabrik/fabrik/commit/c03fbe7766cac30082e16e8ea81526153adf3f0d

    -- hugh
     
  11. merlino68

    merlino68 Member

    Level: Supporter
    Perfect
    Thank you all for the answers and for the quick solution;)

    -- hugh
     
  12. 7webcreator

    7webcreator Member

    Level: Standard
    Thank you very much. That's solved my problem too.
     

Share This Page