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.

Pre Render Address

  1. Hello, I am guessing this has been addressed here somewhere and I am just can't find it. I am having trouble pre rendering the address field.

    this is where I am at right now inside the function :

    $street =  get_post_meta($post->ID, 'street', true);
    $city =  get_post_meta($post->ID, 'city', true);
    $state =  get_post_meta($post->ID, 'state', true);
    $zip =  get_post_meta($post->ID, 'zip', true);
    
        $inputs = array(
                        array("id" => 15.1, "defaultValue" => $street),
                        array("id" => 15.3, "defaultValue" => $city),
                        array("id" => 15.4, "defaultValue" => $state),
                        array("id" => 15.5, "defaultValue" => $zip),
                    );
    
     foreach($form["fields"] as &$field){
    
    	if($field["id"] == 15){
    		$field["defaultValue"] = $inputs;
    	}
     }
     return $form;
    }
    Posted 6 years ago on Friday December 28, 2012 | Permalink
  2. David Peralty
    Administrator

    Which of our hooks are you trying to use to do this? You have this in your theme's functions.php file?

    Posted 6 years ago on Friday December 28, 2012 | Permalink
  3. Thanks for the reply

    Uses gform_pre_render, its on a template, it is part of a large profile form. There are many other fields on the form, which work, so it is firing right. Just can't seem to pre-render this one field.

    Posted 6 years ago on Friday December 28, 2012 | Permalink
  4. David Peralty
    Administrator

    I asked one of our developers and he said for the address field that you should use our gform_field_value hook with the parameter name you gave for the input as it will do the address field without issue. That will allow you to get back on track.

    Posted 6 years ago on Friday December 28, 2012 | Permalink
  5. Thanks, I was trying to force that one method. The parameter worked much better. Much appreciated!

    Posted 6 years ago on Friday December 28, 2012 | Permalink
  6. David Peralty
    Administrator

    Glad it got sorted, I can definitely empathize with wanting everything in one function. All my best!

    Posted 6 years ago on Friday December 28, 2012 | Permalink

This topic has been resolved and has been closed to new replies.