• 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_updated_batch_fields

  1. Description
  2. Usage
  3. Parameters
  4. Examples
    1. Listen for updates on a specific field.
    2. Select All Populated Checkboxes
    3. Auto-submit after fields are populated via QR code scan.

Description

An event that gets triggered when Populate Anything has dynamically updated a field’s choices or value.

Usage

$( document ).on( 'gppa_updated_batch_fields', function() { 
    // Do your magic!
} );

Parameters

  • event Event

    The JavaScript event for the gppa_updated_batch_fields request.

  • formId int

    The ID of the form for which the fields were updated.

  • updatedFieldIds array

    An array of IDs for fields that were updated.

Examples

Listen for updates on a specific field.

/**
 * Gravity Perks // Populate Anything // Listen for Populate Anything Updates on a Specific Field
 * https://gravitywiz.com/documentation/gravity-forms-populate-anything/
 */
$( document ).on( 'gppa_updated_batch_fields', function( e, formId, updatedFieldIDs ) {
	var targetFieldId = 3;
	if ( parseInt( formId ) === GFFORMID && $.inArray( String( targetFieldId ), updatedFieldIDs ) !== -1 ) {
		console.log( 'Target field updated!' );
	}
} );

Select All Populated Checkboxes

/**
 * Gravity Perks // GP Populate Anything // Automatically Check Checkboxes
 * https://gravitywiz.com/documentation/gravity-forms-populate-anything
 *
 * Instructions:
 *     1. Install our free Custom Javascript for Gravity Forms plugin.
 *        Download the plugin here: https://gravitywiz.com/gravity-forms-custom-javascript/
 *     2. Copy and paste the snippet into the editor of the Custom Javascript for Gravity Forms plugin.
 *.    3. This snippet is meant to be a starting point. You will need to update the selectors accordingly
 */

// Select all choices for field ID 1 on initial load
jQuery('#button_1_select_all').each(function() {
	gformToggleCheckboxes(this);
});

// Select all choices for field ID 2 whenever its choices are repopulated dynamically
jQuery(document).on('gppa_updated_batch_fields', function(event, formId, fieldIds) {
	if (formId != GFFORMID) {
		return;
	}
	
	jQuery('#button_2_select_all').each(function() {
		gformToggleCheckboxes(this);
	});
})

Auto-submit after fields are populated via QR code scan.

Use GP QR Code to scan a QR code and Populate Anything to dynamically populate data based on the scanned QR code. Then, with this snippet, you can wait for Populate Anything to finish updating the fields and automatically submit the form.

/**
 * Gravity Perks // GP QR Code // Automatically Submit After Successful Scan (w/ Populate Anything)
 * https://gravitywiz.com/documentation/gravity-forms-qr-code/
 *
 * You want to auto-submit the form after you've scanned a QR code but you're using Populate Anything
 * to populate other fields based on the value scanned. You need to wait for Populate Anything to
 * finish fetching and populating that data before the form can be submitted. This snippet handles
 * that logic for you.
 *
 * We recommend installing this snippet with our free Custom Javascript plugin:
 * https://gravitywiz.com/gravity-forms-custom-javascript/
 */
gform.addAction( 'gpqr_on_scan_success', function( decodedText, decodedResult, gpqrObj ) {
	$( document ).off( 'gppa_updated_batch_fields.gpqr' );
	$( document ).on( 'gppa_updated_batch_fields.gpqr', function( event, formId ) {	
		if ( gpqrObj.formId == formId ) {
			setTimeout( function() {
				$( '#gform_{0}'.format( formId ) ).submit();
			} );
		}
	} );
} );

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