Dynamically setting an Administrative Field value based on dropdown selecting [RESOLVED]

Hi Everyone,

I am currently evaluating Gravity Forms to see if it has the functionality that our business needs.

In general what I want is a Form that runs calculations based on user selections. So if a user selection Option A, with a room square footage of X, in City Y, I can run calculations as they make their changes to update values. We need the calculations to update as they make their selections and not after the form is submitted.

Is Gravity Forms the right tool for this task? It seemed like it at first but after trying it out I cannot figure out how to use the hooks to update values.

For my first test I want to update the value of an Administrative Field when a user changes their selection in a Drop Down, but I cannot figure out how to do this. I am fine writing custom PHP or Javascript code if need be, but I cannot seem to find the correct hooks.

I thought that something like the following would work (as a test) for the dropdown called region but my function never seems to get called:

add_action( 'gform_update_region', 'region_changed', 10, 3 );

function region_changed( $entry_id, $property_value, $previous_value ) {
   GFCommon::log_debug($entry_id);
}

Am I missing something? Or am I looking to implement functionality that Gravity Forms is not suited for?

Thanks

gform_update_region

It looks like you are using this hook:

The PROPERTY_NAME portion of that hook would need to be one of the Gravity Forms entry properties (I left out the entry ID, ID, and post ID):

  • date_created
  • date_updated
  • is_starred
  • is_read
  • ip
  • source_url
  • user_agent
  • currency
  • payment_status
  • payment_date
  • payment_amount
  • payment_method
  • transaction_id
  • is_fulfilled
  • created_by
  • transaction_type
  • status

So your filter name would be one of these, depending on which property you are watching for a change:

gform_update_date_created
gform_update_date_updated
gform_update_is_starred
gform_update_is_read
gform_update_ip
gform_update_source_url
gform_update_user_agent
gform_update_currency
gform_update_payment_status
gform_update_payment_date
gform_update_payment_amount
gform_update_payment_method
gform_update_transaction_id
gform_update_is_fulfilled
gform_update_created_by
gform_update_transaction_type
gform_update_status

Now, I don’t think this has anything to do with what you actually need to accomplish. Unless I am way off, I think you should forget about the gform_update_*property* filter, and we’ll go back to the original question.

Thanks for the reply and the clarification, you are absolutely correct. I was just confused by what was meant in the documentation by “Property Name”.

I ended up using JavaScript get change event and then update my calculations that way:

$('.region_gp  input').change(function(){
	updateCalculation();
});

Sorry for taking so long to reply I missed the notification in my inbox.

1 Like