Enable Custom GF_Field to be used for Calculations

Hi there,

I am building a budgeting calculator with a custom ‘income or expense’ field which allows the user to enter an amount, and then select from an accompanying dropdown whether the expense is daily, monthly, annual etc.

The field then returns a value based on converting the entered value into a monthly amount.

https://github.com/benjeewest/gf-income-expense-field/blob/main/gf-income-expenses-field.php

I have (I think) successfully created the custom field, but would be really grateful for some help with two issues:

  • How do I enable my custom field type to be used for calculations? Ideally I’d want to display a total at the end of the form. I know by default Gravity Forms allows calculations on ‘number’ and ‘product’ fields. I noticed that common.php has a function ‘is_valid_for_calculation’. Can this be overridden?

  • I’m also looking for the best way to add currency support to one of the fields. Can I do this using the API, or do I need to add the JS myself?

Thank you for anyone’s help.

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.