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.

Echo specific Gravity Form fields in a multi-step form into sidebar widget

  1. matsilva
    Member

    I want to echo a few specific fields from the submitted form data after the first step (Which by the way I have already create to work "in" the form) but I am unable to echo outside of the form into a Sidebar widget.

    David over at http://gravitywiz.com/2012/08/04/better-pre-submission-confirmation/
    Stated I can echo this into a widget $_POST['input_1']

    However this does not seem to work, it doesn't return anything.

    Would anyone have any insight as to how to properly echo form fields from a multistep form into the sidebar using gravity forms?

    The main goal is the PayPal Pro price Total field and a few other fields from the first step.

    Running Gravity Forms 1.6.9 WordPress 3.4.2

    Posted 11 years ago on Sunday October 28, 2012 | Permalink
  2. If you dump the $_POST after the first step and see what is contains? If it contains the value you want to echo, I don't see why this would not work. We need to see what the $_POST contains though to be sure the value is there.

    Posted 11 years ago on Sunday October 28, 2012 | Permalink
  3. matsilva
    Member

    I think it's the mark up I have wrong. Is this correct
    <?php echo $_POST['input_1']; ?>

    Posted 11 years ago on Sunday October 28, 2012 | Permalink
  4. matsilva
    Member

    I have also tried

    <?php echo $_POST['input_1_7']; ?>

    if it is supposed to be form specific however this did not work for me either.

    Posted 11 years ago on Sunday October 28, 2012 | Permalink
  5. matsilva
    Member

    Is it possible to use jQuery? Just want to find a solution and I haven't found anything on the interwebs that covers this for Gravity Forms.

    Posted 11 years ago on Monday October 29, 2012 | Permalink
  6. Can you post the results of print_r($_POST) please? So we can see if the value is in the $_POST in the first place.

    It's certainly possible to do this with jQuery, but it should also be possible as you initially described it. The first step will be to determine where you can get the value from. We need to see if it's in the $_POST before we can try using it anywhere.

    Posted 11 years ago on Monday October 29, 2012 | Permalink
  7. matsilva
    Member

    When I do that I get nothing being displayed at all.

    Posted 11 years ago on Monday October 29, 2012 | Permalink
  8. OK, that means the $_POST does not hold the value. In that case it sounds like you will need to use jQuery. Also, can you post a link to your site where we can see what you're trying to do?

    Posted 11 years ago on Monday October 29, 2012 | Permalink
  9. matsilva
    Member

    No problem.

    http://bit.ly/Q0Ts2k

    I was using the sidebar plugin as David pointed out for php in widgets but I can't seem to find a solution for this.

    Posted 11 years ago on Monday October 29, 2012 | Permalink
  10. matsilva
    Member

    Any jQuery snippets hanging around that this would work with?

    Posted 11 years ago on Monday October 29, 2012 | Permalink
  11. matsilva
    Member

    Would this require creating a custom function?

    Posted 11 years ago on Tuesday October 30, 2012 | Permalink
  12. matsilva
    Member

    For anyone else's reference I was able to find out why this wasn't working. You must have AJAX turned off for the specific form and then you will be able to echo submitted fields into the sidebar.

    However it doesn't seem to work with the standard image upload and displaying that in the sidebar. Still looking for a workaround for this.

    Posted 11 years ago on Tuesday October 30, 2012 | Permalink
  13. Thank you for the update on the AJAX functionality.

    For the image upload, you might want to look at the $_FILES global, rather than $_POST.

    Posted 11 years ago on Wednesday October 31, 2012 | Permalink
  14. matsilva
    Member

    Yes I was able to get that far however it is only returning the word "Array".

    David @ Gravity Wiz mentioned to me in an email that it may be better to focus on the function he has inside of the Better Pre-Submission Confirmation here http://gravitywiz.com/2012/08/04/better-pre-submission-confirmation/

    by getting it to work with the single field ID. I am not super sure where to start with echoing it but here is the function

    public static function preview_image_display($field, $form, $value) {
    
            // need to get the tmp $file_info to retrieve real uploaded filename, otherwise will display ugly tmp name
            $input_name = "input_" . str_replace('.', '_', $field['id']);
            $file_info = RGFormsModel::get_temp_filename($form['id'], $input_name);
    
            $file_path = $value;
            if(!empty($file_path)){
                $file_path = esc_attr(str_replace(" ", "%20", $file_path));
                $value = "<a href='$file_path' target='_blank' title='" . __("Click to view", "gravityforms") . "'>" . $file_info['uploaded_filename'] . "</a>";
            }
            return $value;
    
        }
    Posted 11 years ago on Wednesday October 31, 2012 | Permalink
  15. You will need to get all the values out of the files array with something like print_r($_FILES);

    However, if you're working with David Smith, you're in good hands.

    Posted 11 years ago on Wednesday October 31, 2012 | Permalink
  16. matsilva
    Member

    That was what I did actually :)

    However David mentioned not using $_FILES array for this. He wasn't able to give me too much to go on and has helped me this far. I think I just need to find the correct markup to echo the $value of the uploaded image into the sidebar.

    That is where I am currently stumped so far.

    Posted 11 years ago on Wednesday October 31, 2012 | Permalink
  17. When you print_r($_FILES) you still get array? If that's the case, you can use var_dump($_FILES) which might work.

    Posted 11 years ago on Wednesday October 31, 2012 | Permalink
  18. matsilva
    Member

    Yes just array. When using the var_dump I received

    array(1) { ["input_2"]=> array(5) { ["name"]=> string(40) "Screen Shot 2012-10-28 at 2.19.33 AM.png" ["type"]=> string(9) "image/png" ["tmp_name"]=> string(14) "/tmp/phpamDHzP" ["error"]=> int(0) ["size"]=> int(59661) } }

    Posted 11 years ago on Wednesday October 31, 2012 | Permalink
  19. OK, that's good. The file is in a tmp folder because the form has not yet been submitted. Is this the information you needed? I'm not sure how long that image location will be valid because it will be removed from there after the form is submitted.

    Posted 11 years ago on Wednesday October 31, 2012 | Permalink
  20. matsilva
    Member

    I believe it is. I am really just trying to echo the uploaded image into the sidebar of the form as a preview of what was uploaded.

    I just don't know how to pull it out of this array to display correctly. I can do it perfectly with no hitch inside a form field html element but not in the sidebar.

    Posted 11 years ago on Wednesday October 31, 2012 | Permalink
  21. How are you doing it in the HTML field in the form?

    Posted 11 years ago on Thursday November 1, 2012 | Permalink