Copy value from calculations field to currency field
-
Hi there,
I have a form with a simple calculation field (sum of some other fields), and a currency field. I use the value of the currency field on submission in the
forminator_form_after_save_entry
andforminator_form_after_handle_submit
hook to create a payment link.My issue is that the value from the calculation field is not visible in the $_POST variable on submission (in opposition to the currency value, which is visible). Therefore, I was thinking about to copy the value from the calculation field to the currency field, when there are changes in the form. I have tried using this code:
jQuery(document).ready(function($){
jQuery('[name=currency-1]').prop('readonly', true);
jQuery('#forminator-module-2420').on('change', function(event){
var calculation_val = jQuery('[name=calculation-2]').val();
jQuery('[name=currency-1]').val(Number(calculation_val));
});
});However, I am also using the awesome repeater field, and the input elements in new field groups is not triggering the change event bound to the form element. Therefore, the code above only works for fields that were present on page load.
Is there a way to use the calculation field directly in the entry submission, or would it be better to copy the value from the calculation field to the currency field? If so, how should I do?
Best Regards,
Peter B. Stidsen
- You must be logged in to reply to this topic.