So I have this wee code bit to get an ACF field and show it within my form in an HTML block this php code is in my functions.php:
function addpaypalbutton($form) {
if(empty($_POST['is_submit_9'])){
foreach($form["fields"] as &$field){
if($field["id"] == 30){
if(get_field('paypal_nappi')){
$field["content"] = get_field('paypal_nappi');
}
}
}
}
return $form;
}
add_filter('gform_pre_render_9','addpaypalbutton');
add_filter( 'gform_pre_validation_9', 'addpaypalbutton' );
The problem is that even though the paypal button shows on the actual form. The form won’t save at all when there’s html in the $field[“content”] variable. If I set it to field["content"] = "I'm here" it works just fine and saves. I tried to make it ignore the whole thing on submission (since it only needs to show on the front end, doesn't need to save anywhere) with the if empty(_POST bit) but it still seems to run it anyway.
I’d appreciate any help, I’ve debugged down to that one line and it’s almost 10pm on a friday night, brain is frieedddd.