• Home
  • Pricing
  • Free Resources
  • About
  • Docs
  • Support
  • Account

Gravity Wiz

Magically enhanced tutorials, snippets and plugins for Gravity Forms!

  • Gravity Perks
    • Gravity Perks
    • Pricing
  • Blog
    • Free Resources
    • About
  • Support
    • Docs
    • Support
    • Account

gppa_template_rows

  1. Description
  2. Usage
  3. Parameters
  4. Since
  5. Examples
    1. Add A Custom Choice Template

Description

JavaScript filter to modify the available choice/template templates available in the Form Editor.

Usage

gform.addFilter( 'gppa_input_choice', 'my_custom_function' );

Parameters

  • templateRows array

    The available template rows. Each template should have an “id” string, “label” string, and “required” boolean.

  • field object

    The current field shown in the Form Editor.

  • populate string

    What’s being populated. Either choices or values.

Since

This JavaScript filter is available since Gravity Forms Populate Anything 1.0-beta-4.116.

Examples

Add A Custom Choice Template

Add a choice template named image. This pairs well with the gppa_input_choice PHP filter.

<?php
/**
 * Gravity Perks // Populate Anything // Add A Custom Choice Template
 * https://gravitywiz.com/documentation/gravity-forms-populate-anything/
 *
 * Choice templates allow you to map data to different properties of your Gravity Forms choices.
 *
 * In this example, we demonstrate how to create a new template for a theoretical "image" choice property.
 * With this in place, you would be able to select a value in the Populate Anything choices UI that is
 * mapped to the "image" property for each choice.
 */
add_action( 'admin_print_footer_scripts', function () {
	if ( ! is_callable( 'GFCommon::is_form_editor' ) || ! GFCommon::is_form_editor() ) {
		return;
	}
	?>
	<script>
	window.gform.addFilter( 'gppa_template_rows', function (templateRows, field, populate) {
		if ( populate !== 'choices' ) {
			return templateRows;	
		}
		templateRows.push( {
			id: 'image',
			label: 'Image',
		} );
		return templateRows;
	} );
	</script>
	<?php
} );

add_filter( 'gppa_input_choice', function( $choice, $field, $object, $objects ) {
	$choice['image'] = gp_populate_anything()->process_template( $field, 'image', $object, 'choices', $objects );
	return $choice;
}, 10, 4 );

All Perks

  • GF Address Autocomplete
  • GF Advanced Calculations
  • GF Advanced Phone Field
  • GF Advanced Save & Continue
  • GF Auto List Field
  • GF Auto Login
  • GF Better User Activation
  • GF Blocklist
  • GF Conditional Logic Dates
  • GF Conditional Pricing
  • GF Copy Cat
  • GF Date Time Calculator
  • GF Disable Entry Creation
  • GF Easy Passthrough
  • GF eCommerce Fields
  • GF Email Users
  • GF Entry Blocks
  • GF Expand Textareas
  • GF File Renamer
  • GF File Upload Pro
  • GF Google Sheets
  • GF Inventory
  • GF Limit Checkboxes
  • GF Limit Choices
  • GF Limit Dates
  • GF Limit Submissions
  • GF Live Preview
  • GF Media Library
  • GF Multi-Page Navigation
  • GF Nested Forms
  • GF Notification Scheduler
  • GF Page Transitions
  • GF Pay Per Word
  • GF PayPal One-time Fee
  • GF Placeholder
  • GF Populate Anything
  • GF Post Content Merge Tags
  • GF Preview Submission
  • GF Price Range
  • GF QR Code
  • GF Randomizer
  • GF Read Only
  • GF Reload Form
  • GF Terms Of Service
  • GF Unique ID
  • GF Word Count

Copyright © 2023 · Powered by WordPress · Gravity Wiz LLC

  • Support
  • Affiliates
  • About
  • Sitemap
  • Terms & Conditions of Use
  • Privacy Policy
  • Cookies Policy