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.

Outputting a PHP echo in a hidden field

  1. Is there an easy way to get this PHP echo to output in a hidden field?

    <?php echo $visited_pages_string  ?>

    The tooltip next to the "Allow fields to be populated dynamically" seems to indicate I can insert a shortcode there; but I tried tried putting it in a hidden field's default value as both PHP code and a shortcode, but that didn't work.

    Posted 11 years ago on Wednesday March 6, 2013 | Permalink
  2. David Peralty

    Have a look at this hook: http://www.gravityhelp.com/documentation/page/Gform_field_value_$parameter_name

    You'll want to put any PHP code in the theme's functions.php file. All my best!

    Posted 11 years ago on Wednesday March 6, 2013 | Permalink
  3. @David Thanks!

    Forgive me, but I'm not a PHP programmer. I believe I understand that I need replace "date" in the example code on that page so it looks like this:

    <?php
    add_filter("gform_field_value_url", "populate_url");
    function populate_url($value){
       return "10/10/2010";
    }
    ?>

    But I'm not sure what I would put in

    $value

    or

    return "10/10/2010";
    Posted 11 years ago on Wednesday March 6, 2013 | Permalink
  4. David Peralty

    You would want

    return $visited_pages_string;
    Posted 11 years ago on Wednesday March 6, 2013 | Permalink
  5. I added this code to functions.php

    add_filter("gform_field_value_url", "populate_url");
    function populate_url($value){
       return $visited_pages_string;
    }

    and created a hidden field called "url" a chcked "Allow field to be populated dynamically" and entered the parameter name "url" and it's just outputting an empty value in the <input> tag.

    Posted 11 years ago on Wednesday March 6, 2013 | Permalink
  6. David Peralty

    Can you try

    return "test value";

    To make sure your function is working as expected.

    Posted 11 years ago on Wednesday March 6, 2013 | Permalink
  7. That didn't work either. :(

    Posted 11 years ago on Wednesday March 6, 2013 | Permalink
  8. rcDev
    Member

    Did you set it to "Allow field to be populated dynamically" and make the parameter name "url"?

    Posted 11 years ago on Monday March 11, 2013 | Permalink
  9. David Peralty

    Hopefully, he's been able to figure it out by now, and just hasn't returned to let us know.

    Posted 11 years ago on Monday March 11, 2013 | Permalink