Form Object Gravity Forms

Gravity Forms.
I try to manipulate the form fields before they are rendered with

add_filter("gform_pre_render", "my_function", 10, 5);

function my_function($form){
...
$form["fields"][0]["content"] = 'This is a html-block'
}

Like this, I can pass the html-block’s content assumed the html is the first field on the form.
How can I target a field by id? Let’s say the above html-block-field has the field id 13.

Related posts

1 comment

  1. According to this page about the form fields object, it looks like you’d need to do something like this:

    $my_id = '37';
    foreach($form['fields'] as $field){
        if($field['id'] == $my_id){
            $field['content'] = 'This is a html-block';
        }
    }
    

    where $my_id is the id of the field you are targeting

Comments are closed.