Skip to content

Instantly share code, notes, and snippets.

@mager19
Created March 31, 2022 14:52
Show Gist options
  • Save mager19/c8509b728bcb8dc0f2460c3808951457 to your computer and use it in GitHub Desktop.
Save mager19/c8509b728bcb8dc0f2460c3808951457 to your computer and use it in GitHub Desktop.
assing value to hidden field pre submittion
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