I am currently using the Computed Field module to calculate field in Field Collection and use PHP code to generate the formula. The problem is that the user does not enough PHP skill to write that PHP code. So are there any alternatives that allow users to choose which fields and calculations instead of using PHP code?


Using rules you can do basic calculations with field values and write the result into an other field. If you do the calculation after an instance of your content type has been saved you make sure the value is always up to date.

Of course you can implement your own action as well and hook it into rules. See hook_rules_action_info.

Whether your users find rules easy to manage and you can trust them to give them access to the rules system is an other story. Depending on what you want to evaluate you might just add some fields to get all the information you need and add a custom action to do the evaluation.

  • +1. if you want to prevent them from executing raw php, disable PHP module.
    – AKS
    Sep 8 '12 at 1:14

A not commonly known/used alternative to the Computed Field module, is the (fairly new) Math Field module (for D7). Some more details about this module (from its project page):

The Math Field module defines a new field type to dynamically calculate values on entity forms. This is an alternative to Computed Field that does not require the use of PHP Filter.

Math expression fields are dynamically updated via ajax on the entity form as soon as all necessary fields are populated. If JavaScript is disabled, the field will be evaluated when the form is submitted. The result is stored in the database when the form is submitted.

For more details (step-by-step instructions), refer to either of these links:

However, Math Field does not yet support Field Collections (#2573643: Support the Field Collection module). So in order for it to work in this specific case, you might have to rework the Field Collection you're using in something Math Field does support.

Known issues

As this is a fairly new D7 module, there are still a few other (known) issues with it, as mentioned also on its project page:

Bonus: you would not need the "PHP filter" (IMO only that should be a valid reason to investigate this alternative) ...

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.