1. Fabrik 3.8.1 has been released. It is mostly bug fixes and feature enhancements, but does include two new plugins (push notifications, and the sequence element). As usual we strongly recommend testing the new release on a sandbox if your application is mission critical, and always do an Akeeba backup before updating.
    Dismiss Notice

Server 500 Error with Calc Watch Element

Discussion in 'Community' started by fudge4u, Sep 12, 2018 at 2:54 AM.

  1. fudge4u

    fudge4u Member

    Level: Community
    I am trying to create a Cascading Dropdown Menu, and would like to use a calc element as the watch element. But every time I set a calc element to be the watch element, I get the 500 Internal Server Error.

    Is it possible, or is there a workaround to being able to create this dropdown menu?

    Using the latest Joomla! code and the latest GitHub update.
     
  2. cheesegrits

    cheesegrits Support Gopher Staff Member

    Level: Community
    Hmmm, there seems to be an infinite recursion. The CDD is calling a function in the calc code, which calls the same function back from the CDD, which calls the function back from the calc, etc.

    I'm not entirely sure this is fixable. So the answer may be "no, you can't use a calc as the watched element for a CDD".

    I'll take another look at the code, see if I can find a fix.

    -- hugh
     
  3. fudge4u

    fudge4u Member

    Level: Community
    That would be great if there is a fix for that. In the mean time, is there a way that the calc element can assign the calculated value to a field element, which I can then use as the watch element?
     
  4. cheesegrits

    cheesegrits Support Gopher Staff Member

    Level: Community
    You can use a form PHP plugin, running 'onBeforeProcess' to assign values to filed elements, instead of using a calc.

    So you can do pretty much the same code you have in your calc, but instead of returning it, do ...

    Code (Text):

    // your code goes here to set $result
    $formModel->updateFormData('yourtable___yourelement', $result, true);
     
    If you are using inline code (rather than a included file) you can use element placeholders in your code, like {yourtable___whatever}. Or you can access the formData array, like $formModel->formData['yourtable___whatever'].

    You can (probably) do this instead of, rather than as well as, a calc. The only situation this might not be true in is if your calc values can be affected outside of the form submission process, and you have "Calc on save only" set to No, such that they calc on list load. For example if you are displaying some time based value relative to "now", etc.

    -- hugh
     

Share This Page