PLEASE NOTE: These forums are no longer utilized and are provided as an archive for informational purposes only. All support issues will be handled via email using our support ticket system. For more detailed information on this change, please see this blog post.

Problem with gform_pre_render and a custom field type

  1. Hi!

    I created a custom field type and i try to change the defaultValue by using the gform_pre_render, but somehow its not working.

    Here is the gform_pre_render function:

    add_filter("gform_pre_render", "populate_field");
    				function populate_field($form){
    					$postID = $_GET['id'];
    				    if($form["id"] != 5)
    				       return $form;
    				    foreach($form["fields"] as &$field) {
    				        if($field["id"] == 34){
    				            $field["defaultValue"] = 'just a test default value';
    				    return $form;

    So as you can see, nothing special, however, its not working. If i set the default value in the admin panel, its working fine, but i can't change it like this. I also tried to change the description, and surprisingly that is working fine.

    Any idea? Thanks

    Posted 11 years ago on Wednesday March 27, 2013 | Permalink
  2. Can you share the code you used to create your custom field? Please share all the custom code you are using. Use or please for lengthy code.

    Posted 11 years ago on Thursday March 28, 2013 | Permalink
  3. Well, not exactly i created it, but its definitely a custom made field, thats what i tried to explain somehow:) You can find it here:

    By default, it doesn't support the defaultValue option, so i changed the code in line 124 from this:

    wp_editor('', $input_id, $args);

    To this:

    wp_editor($field["defaultValue"], $input_id, $args);
    Posted 11 years ago on Thursday March 28, 2013 | Permalink
  4. Have you tried to contact that plugin's author for their advice on adding a default value to the field? I'm not familiar with that plugin at all to know the correct way to do it.

    Posted 11 years ago on Sunday March 31, 2013 | Permalink