GField tag
Due to complex Gravity Forms entry data structure getting entry field values requires multiple nested loops and could result in a complex markup which is hard to use for less technically savvy Loops&Logic users.
GField
tag is aimed to allow "flattening" loops and make the markup more human readable.
GField Attributes
id
- (mandatory) A Field ID which Data should be displayedentry_id
- Current Entry id from which we display field values. This attribute is not needed except when we want to display the field value within a nested loop - in that case theentry_id
attribute is mandatory.value_key
- Attribute which determines which part of the field value we want to display. There are some field types, however, which are simple values and the "value_key" is not needed.label
- Returns field label.type
- Returns field type.input_type
- Returns field input type.
You can see a demo for Loops for Gravity here and some more examples here.
GField Usage for different Gravity Forms field types
Here are examples of GField
usage grouped by Gravity Forms fields types:
- Standard Fields
- Advanced Fields
- Survey AddOn Fields
- Poll AddOn Fields
- Quiz AddOn Fields
- Post Fields
- Pricing Fields
Standard Fields scroll to top
Field types: multiselect, select, radio, checkbox
Available keys:
- text
- value
Usage for: select, radio:
<GField id="1" value_key="text"/>
<GField id="1" value_key="value"/>
Usage for: multiselect, checkbox:
<Loop list="{GField id=1}" >
<Loop map="{Field}">
<Field text />
<Field value />
</Loop>
</Loop>
Field types: text, textarea, number
Available keys:
- no keys, a simple value
Usage for: text, textarea, number:
<GField id="1"/>
Advanced Fields scroll to top
Field types: name
Available keys:
- prefix
- first
- middle
- last
- suffix
Usage for: name
<GField id="1" value_key="prefix"/>
<GField id="1" value_key="first"/>
<GField id="1" value_key="middle"/>
<GField id="1" value_key="last"/>
<GField id="1" value_key="suffix"/>
Field types: address
Available keys:
- street
- street2
- city
- state
- zip
- country
Usage for: address
<GField id="1" value_key="street" />
<GField id="1" value_key="street2" />
<GField id="1" value_key="city" />
<GField id="1" value_key="state" />
<GField id="1" value_key="zip" />
<GField id="1" value_key="country" />
Field types: consent
Available keys:
- text
- description
Usage for: consent
<GField id="1" value_key="text" />
<GField id="1" value_key="description" />
Field types: fileupload
Available keys:
- no keys, a simple list
Usage for: fileupload
<Loop list="{GField id=1}" >
<Field/>
</Loop>
Field types: time, date, email, phone, website, list
Available keys:
- no keys, a simple value
Usage for: time, date ,email, phone, website,list:
<GField id="1"/>
Survey Fields scroll to top
Field input types: radio, select, checkbox
Available keys:
- text
- value
Usage for: select, radio:
<GField id="1" value_key="text"/>
<GField id="1" value_key="value"/>
Usage for: checkbox:
<Loop list="{GField id=1}" >
<Loop map="{Field}">
<Field text />
<Field value />
</Loop>
</Loop>
Field input types: text, textarea
available keys: no keys, a simple value
Usage for: text, textarea:
<GField id="1"/>
Field input types: likert
Available keys:
- row
- choice
- score
Usage for: likert:
<Loop list="{GField id=1}" >
<Loop map="{Field}">
<Field row />
<Field choice />
<Field score />
</Loop>
</Loop>
Field input types: rank
Available keys:
- no keys, a simple list
Usage for: rank:
<Loop list="{GField id=1}" >
<Field/>
</Loop>
Field input types: rating
Available keys:
- text
- value
Usage for: rating
<GField id="1" value_key="text"/>
<GField id="1" value_key="value"/>
Poll Fields scroll to top
Field input types: radio, select, checkbox(checkbox type represents list Loop of maps )
Available keys:
- text
- value
- results - results key represents a list loop of maps with available keys: label, total_entries, ratio
Usage for: select, radio:
<GField id="1" value_key="text"/>
<GField id="1" value_key="value"/>
Usage for: checkbox:
<Loop list="{GField id=1}" >
<Loop map="{Field}">
<Field text />
<Field value />
</Loop>
</Loop>
Usage for results key:
<Loop list="{GField id=1 value_key=results}" >
<Loop map="{Field}" >
<Field label />
<Field total_entries />
<Field ratio />
</Loop>
</Loop>
Quiz Fields scroll to top
Field input types: radio, select, checkbox
Available keys:
- text
- value
- is_correct
- weight
Usage for: select, radio:
<GField id="1" value_key="text"/>
<GField id="1" value_key="value"/>
<GField id="1" value_key="is_correct"/>
<GField id="1" value_key="weight"/>
Usage checkbox:
<Loop list="{GField id=1}" >
<Loop map="{Field}">
<Field text />
<Field value />
<Field is_correct />
<Field weight />
</Loop>
</Loop>
Post Fields scroll to top
Field types: post_title, post_excerpt, post_content, post_tags
Available keys:
- no keys, a simple value
Usage for: post_title, post_excerpt, post_content , post_tags
<GField id="1"/>
Field types: post_category
Available keys:
- id
- name
Usage post_category:
<Loop list="{GField id=1}" >
<Loop map="{Field}">
<Field text />
<Field value />
</Loop>
</Loop>
Field types: post_image
Available keys:
- url
- title
- caption
- description
Usage for: post_image
<GField id="1" value_key="url"/>
<GField id="1" value_key="title"/>
<GField id="1" value_key="caption"/>
<GField id="1" value_key="description"/>
Pricing Fields scroll to top
Field types: product, shipping
Available keys:
- name
- price
Usage for: product, shipping:
<GField id="1" value_key="name"/>
<GField id="1" value_key="price"/>
Field types: quantity, total
Available keys:
- no keys, a simple value
Usage for: quantity, total
<GField id="1"/>
Field types: option
Available keys:
- name
- price
Usage for: option
<Loop list="{GField id=1}" >
<Loop map="{Field}">
<Field name/>
<Field price />
</Loop>
</Loop>