If Im not missing something, the Calculate a Value option has only 4 basic functions available. It would be great if we could some php code to be able to make some advanced calculations here.

Thanks...

Comments

mitchell’s picture

> If Im not missing something, the Calculate a Value option has only 4 basic functions available.
That's accurate. There isn't any php.module integration with this action for something like a PHP operator.

> ...to be able to make some advanced calculations here.
Could you please be more specific? Perhaps we might be able include these calculations in a generic, reusable fashion.

hgurol’s picture

Hard to be specific. A rounding function would be great. I was thinking more about mixing text with calculated values.

I have two weight fields both for US units (ounce, pound) and for European units (gram, kilogram) where the user provides one of them, not both. Im trying to calculate the not provided weight field and then print both of them like "34 oz / 963 gr". Im working on this for more than a week now and still couldnt manage to do it. Data type conversions, rounding up numbers etc etc, too many problems I have faced.

I thought to be able to use some custom php on the Calculate Value action would solve all of my problems.

zhangtaihao’s picture

Status: Active » Reviewed & tested by the community

Please ignore. Wrong issue.

zhangtaihao’s picture

Status: Reviewed & tested by the community » Active

Restored status.

hgurol’s picture

@mitchell
Did you have time to think about a workaround ?

tr’s picture

Issue summary: View changes
Priority: Major » Normal
Status: Active » Closed (won't fix)

min/max have been added in the years since this was first opened.
If you would like to see additional functions, please open a new issue with a specific proposal. Preferably with a patch+test.

There has been no community interest in adding this feature for almost 7 years now. At this late point in the D7 development cycle there aren't going to be many new features added - those should go into the D8 version of Rules. And in any case, we're simply not going to add the ability to use PHP code here - that's just too dangerous and unnecessary. The best thing to do if you have a specific need to manipulate data in a certain way is to write your own action - then you can do exactly what you want. If you do this, then you can post your action in this queue as a feature request which may be put into Rules if there is community interest.