Last active
April 24, 2017 18:11
-
-
Save Shelob9/c1c43fb720d5db14df3b01a8749d25cb to your computer and use it in GitHub Desktop.
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/
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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; | |
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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