Passing variables to Gravity Forms fields

Reposted as I didn’t have it categorized as loops & logic…

OK so…next trick. In CCS I create a shortcode, define some variable names, then run a gravity forms shortcode from within the CCS shortcode. In the gravity form I use the parameters like [get planname] to populate a field in gravityforms. Works like a charm, and lets you pass data into the gravity form. I’m able to recreate the logic in L&L but when I invoke it doesn’t pass any of the data… Here’s what it currently looks like…

<Loop type=user id=current>
  <If user_field=real_estate_package_id><Set isagent>1</Set>

<Set homeplanid><Url query=homeplanid /></Set>
<Set homesiteid><Url query=homesiteid /></Set>

<Loop type=property>
  <If field=id value="{Get name=homeplanid /}">
  <Set planname><Field title /></Set>

<Loop type=property>
  <If field=id value="{Get name=homesiteid /}">
  <Set sitename><Field title /></Set>  

<Note>Test code - these all show correct values.</Note>
<Get name=planname />|<Get name=homeplanid /><br>
<Get name=sitename />|<Get name=homesiteid /><br>
<Note>End test code</Note>

  [gravityform id=43 title=false]

  [pass global=query fields=homeplanid,homesiteid,sitename,planname,isagent]
  [if user_field=real_estate_author_agent_id compare="exists"]
  [set isagent]1[/set]

  [loop type=property]
  [if field=id compare="=" value={HOMEPLANID}]
  [set planname][field title][/set]
  [if field=id compare="=" value={HOMESITEID}]
  [set sitename][field title][/set]
[gravityform id=43 title=false] 

Loops & Logic Output in GF:

CCS output in Gravity Forms

Woo, that’s quite a trick with CCS and Gravity Forms.

The reason it’s not working is that dynamic tags in L&L can only be used inside templates, unlike shortcodes which are supported in a lot of places. This limitation is by design, to ensure that only admin users have the power to use L&L tags.

One way I can imagine to pass L&L variables to Gravity Forms, is to create a template, for example:

<Get name=planname />|<Get name=homeplanid />

And get that template with a shortcode, like [template id=123].

OK I like where you are going with that - going to try just calling the above template and its logic from within a GF HTML field and see what happens. Will update once tested.

1 Like

So far the trick has been to use the field_values parameter of GravityForms -

  [gravityform id=43 title=false field_values="planname=<Get name=planname />&sitename=<Get name=sitename />"]

This is useful, but somewhat limited. For example, you can’t embed merge tags in HTML fields in a Gravity Form. Also, you in theory could generate a custom list from L&L and populate a gravity drop down on the fly with it. I haven’t gone through all my use cases yet, I’ve started with the easier ones…

It would be useful if you could still encapsulate a shortcode and then use L&L within it. The scenarios are nearly limitless. Encapsulate a slider and populate the overlays with post data. Populate a google map. Etc…

Very limited. For example, I used CCS to populate data into the question labels -

Is [get sitename] Your Listing? But I can’t do that with merge tags or with dynamically populated fields…

Would love a way to do this again…

Also, I’m getting an error message when I move to the second page of a multi-page form that I’m attempting to diagnose. EDIT: error message may be a license issue with staging environment.