Created
March 31, 2022 14:52
-
-
Save mager19/c8509b728bcb8dc0f2460c3808951457 to your computer and use it in GitHub Desktop.
assing value to hidden field pre submittion
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
add_filter("gform_pre_submission_1", "obtainsumvaluesfield", 1); | |
function obtainsumvaluesfield($form) | |
{ | |
// get all entries in this form | |
$entry = GFFormsModel::get_current_lead(); | |
$all = 0; | |
foreach ($form["fields"] as &$field) | |
if ($field->type == 'checkbox') { | |
$field_value = $field->get_value_export($entry, $field->id); | |
$values = explode(', ', $field_value); | |
$all += array_sum($values); | |
} | |
$_POST["input_21"] = $all; | |
return $form; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment