Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Examples of how to trigger a custom JavaScript function when Connected Caldera Forms advances or goes back in the connected forms sequence. See: https://calderaforms.com/doc/triggering-javascript-connected-caldera-forms-changes-forms/
<?php
/**
* Send additional data back to the browser when connected forms advances
*/
add_filter( 'cf_form_connector_return_data', function( $data ) {
//check if right form
//Change form ID for connected form
if ( 'cf1234567' == $data[ 'connected_form_id' ] ) {
//Get data from a field
$field_data = Caldera_Forms::get_field_data( //field ID for field you want data from
'fld1234567', //form configuration for connected form
Caldera_Forms_Forms::get_form( $data[ 'connected_form_id' ] ), //entry ID for connected form
$data[ 'entry_id' ] );
//add to field data to return data
$data[ 'something' ] = $field_data;
//add something else to return data
$data[ 'something_else' ] = 'Hi Ron';
}
return $data;
});
jQuery( document ).on( 'cf.connected', function (event, data ) {
//the ID of the connected form
var connected_form_id = data.connected_form_id;
//the id attribute of the container the connected form is loaded in
var target = data.target;
//Type of connection. Will be advance or back
var type = data.type;
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment