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.
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.
For more details (step-by-step instructions), refer to either of these links:
- the (amazing!) Community documentation about the Math Field module.
- the interesting article about Introducing the Math Field module, which also includes some screenprints to see it at work (such as the the add/edit form example).
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.
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:
- The cTools math expression library causes an error when using function that take more than one parameter. This effects pow(), min(), max() (#1958538: Improve math expression engine).
- Math Field does not yet support multivalue options fields (checkboxes, or multiselect) (#2483453: Add aggregate functions for multivalue fields).
Bonus: you would not need the "PHP filter" (IMO only that should be a valid reason to investigate this alternative) ...