Let's say I have
<input type="number" name="input_2[]" />
I would use the gform_pre_submission hook to convert the input array to a json string
add_action("gform_pre_submission_1", "pre_submission_handler");
function pre_submission_handler($form){
$_POST["input_2"] = json_encode($_POST["input_2"]);
}
Then if I want to render the json string as a list on the Entry detail page I would use the gform_entry_field_value hook like so
add_filter("gform_entry_field_value", "category_names", 10, 4);
function category_names($value, $field, $lead, $form){
if($form['id'] != 1 || $field['id'] != 2)
return $value;
$newvalue = '';
$choices = json_decode($value, true);
foreach($choices as $choice) {
$new_value .= '<li>'.$choice.'</li>';
}
return '<ul>' . $new_value . '</ul>';
}
The only issue I have now is that the email notification returns the json string. Is there anyway to format the values before the email notification is sent?
Posted 11 years ago on Thursday January 17, 2013 |
Permalink