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.

Code to Populate a Hidden Field

  1. bfeldman
    Member

    I am trying to populate a hidden field using the gform_pre_submission hook. I am placing this code in custom_functions.php in my Thesis site. Here is URL to form:
    http://www.halloweenfun.net/submit-site-review/

    Here is the code, but it is invalid, because it is "crashing" my custom_functions.php.
    Any help?

    add_action("gform_pre_submission", "create_attribution");
    
    function create_attribution($form){
    if($form["id"] == '1'){
    $hidden-byline = "Submitted by " . $_POST["input_4"] . ", from ". $_POST["input_5"] . ", who " . $_POST["input_6"] . " affiliated with the site.";
    $_POST["input_8"] = $hidden-byline;
    }
    return $form;
    }
    Posted 14 years ago on Friday November 12, 2010 | Permalink
  2. PHP does not allow dashes in variable names. Try $hidden_byline instead of $hidden-byline.

    Posted 14 years ago on Saturday November 13, 2010 | Permalink
  3. bfeldman
    Member

    Thank you David!

    That's what I get for trying to "impersonate a PHP programmer." But the code itself (after fixing the variable name) ... actually worked! Hooray!!!!

    Posted 14 years ago on Saturday November 13, 2010 | Permalink