1. NOTICE: If you are using Fabrik and update to Joomla 3.10, you will need to update to Fabrik 3.10. And, if you are using Fabrik, do not upgrade to Joomla 4, we do not have a supported version ready for release. More information on a release date coming soon. Also, please note that Fabrik 3.10 will not install on any Joomla sites less than 3.8.
    Dismiss Notice

Calc Element vs Field Element Eval

Discussion in 'Professional Support' started by jmoises, Jul 26, 2018.

  1. jmoises

    jmoises Member

    Level: Community
    Hi Guys, just simple question whats the best aproch to use php code, calc element or field element as eval?

    in terms of resources/procesor/speed etc

    Thansk
     
  2. cheesegrits

    cheesegrits Support Gopher Staff Member

    Level: Community
    Well, the main differences are:

    A field element can only have an eval'ed default, ie. it's initial value on a new form. Once a form is created, and edited, it won't run that default. And that default code is run on the server during the initial form load, not on submit (so you don't have access to whatever values the user assigns to other elements).

    Whereas a calc element runs the code every time you submit the form (new or edit), and optionally whenever the element is displayed (list or details view).

    So the answer is ... it depends what you are trying to achieve. If you can do what you need by just eval'ing a default when a new form is loaded, use a field. If you need to use data from other elements after submission, use a calc.

    -- hugh
     
    jmoises likes this.
  3. jmoises

    jmoises Member

    Level: Community
    Looks that if i just need to store some data, the field and eval is the best option, of course the calc has more way to use it,!!!
    thanks so much
     
  4. cheesegrits

    cheesegrits Support Gopher Staff Member

    Level: Community
    Yes. As long as you don't need any of the values the user is entering in the form.

    -- hugh
     
    jmoises likes this.

Share This Page