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.

pass custom field from a post into a form that post links to

  1. stacybirdy
    Member

    Okay. I have a contact page on my site with a gravity form on it (id=1)... and I want to link various pages on my site to THAT contact page, and have it fill in one of the form fields according to a custom field value located on the page that linked to it.

    EXAMPLES
    *Advertising Page*
    example content: <a href="/contact" rel="nofollow">Click here</a> to request a media kit.
    custom field: subject
    custom field value: Media Kit Request
    --- now those values magically populate the subject field of form id=1 located on the contact page ---
    contact page forms subject line: Media Kit Request

    *Store Page*
    example content: Got an idea for an awesome tshirt? <a href="/contact" rel="nofollow">Let us know!</a>
    custom field: subject
    custom field value: T-Shirt Suggestion
    --- now those values magically populate the subject field of form id=1 located on the contact page ---
    contact page forms subject line: T-Shirt Suggestion

    NOTES
    • I have a custom field called 'subject'
    • I have a field being allowed to populate dynamically in my form with 'subject' as the parameter name
    • I realize my final links will need more than just <a href="/contact"> ...just using it as an example to show its going to that page
    • I understand how to make the 'subject' field from my form populate as the subject of a notification email

    . . . . but how do I populate that subject field in my form based on a value from the referring page?

    Posted 13 years ago on Monday December 13, 2010 | Permalink
  2. If you want to pre-populate values in a form based on values from another page, you would have to pass those values in the query string when you link to the page containing the form.

    In order to do this you would have to setup your form with a hidden field and set it up so that it can be populated dynamically via the query string.

    - Edit your form
    - Add Hidden Field
    - Edit Hidden Field
    - Give Hidden Field a field label value of "Subject"
    - Select Advanced Tab
    - Check the "Allow field to be populated dynamically" checkbox
    - In the parameter name input that appears give it a parameter name of "subject"
    - Save your form

    Now you can pass data to this hidden field by passing the subject to it in the query string.

    Ex.

    http://domain.com/myform?subject=MySubject

    So you would have to change your links to this form so that the subject is passed to it via the query string. You would edit your theme and change your link so it is:

    <a href="/contact?subject=#CUSTOMFIELDVALUE#" rel="nofollow">Click here</a> to request a media kit.

    You would have to use PHP to output the custom field value as the subject.

    The form page does not have access to the custom fields of the referring page so you would have to pass the value to it.

    Then in your notification you can use the Subject field as the value for the Subject.

    Posted 13 years ago on Monday December 13, 2010 | Permalink
  3. stacybirdy
    Member

    THANK YOU!

    i ended up tweaking that just a tad, described below for anyone else who might have a use for it:

    * made a form with a single line text field 'Subject'.... I didn't want this to be hidden I wanted to remind the user the topic of the message and just... idk I just wanted it shown.
    * set it to auto populate, parameter name 'subject'
    * edited the notifications so that the subject of the admins email populated with the value in the Subject field of my form... which will have populated with the value assigned through the link that brought the user TO the form (phew!)
    * went back into my post and linked to it like this You can <a href="/contact?subject=request a media kit" rel="nofollow">request a media kit</a> today and blah blah blah
    * later in the post w was able to do the same thing by switching up what came after the "="... worked perfectly.

    thanks again!

    Posted 13 years ago on Wednesday December 15, 2010 | Permalink