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.

Working with $form object and $entry object

  1. How can I see what the $form object and $entry object look like? I'd like to output them so I can figure out what I need to do to readjust them to work with an API. My thought was to just stub them out for the function, so I'm not having to fill out a form every time I want to test it, but I can't seem to get them to work. I've tried var_dump(), print_r(), echo, etc and can't get the objects. Can someone provide me with what I would have for each $form and $entry. Thanks!

    Posted 11 years ago on Tuesday January 15, 2013 | Permalink
  2. var_dump and print_r will both work. How are you using them? I usually use print_r($entry) or print_r($form) in a gform_after_submission hook, to see what they contain. I normally write that information to a log file and then check that.

    Posted 11 years ago on Tuesday January 15, 2013 | Permalink
  3. Here's what I've got going for a function right now, https://gist.github.com/4541295. I was trying to keep it simple, but this doesn't output to the error_log() for some reason.

    Posted 11 years ago on Tuesday January 15, 2013 | Permalink
  4. I've never gotten that complex. I just do this, which works for me:

    <?php
    // this will work for form 150
    add_action('gform_after_submission_150', 'dump_variables', 10, 2);
    // generic logging function
    function dump_variables($entry, $form) {
        $logfile = '/var/www/htdocs/gravity/gravity_log.txt';
        $fh = fopen($logfile, 'a');
        $ebody  = "FORM:\n" . print_r($form, TRUE);
        $ebody .= "\n\nENTRY:\n" . print_r($entry, TRUE);
        $ebody .= "\n\nPOST:\n" . print_r($_POST, TRUE);
        fwrite($fh, $ebody);
        fclose($fh);
    }

    I called it $ebody at one point because I was emailing the data to myself. I just log it now.

    Posted 11 years ago on Tuesday January 15, 2013 | Permalink
  5. OK great! That helps much easier than what I was doing! I'll see how far I can get now! :)

    Posted 11 years ago on Wednesday January 16, 2013 | Permalink
  6. Let us know if you need help. It was some quick and dirty rudimentary logging I set up a couple times, but it seems to work OK for debugging and getting at the exact format of the $form and $entry objects.

    Posted 11 years ago on Wednesday January 16, 2013 | Permalink