// Inject things into gravity forms fields - This intercepts all GravityForms before displaying them
add_filter( 'gform_pre_render', function($form) {
-/*
-
- // for each field in the form
- foreach ( $form['fields'] as $k => $v ) {
-
- // Check for a specific input field - in this case contact interests
- // This must be the same field name for all forms that need this data
- if ($v['inputName'] == 'contact_interest_options') {
-
- // Inject sample options - *** THIS SHOULD BE FROM THE DATABASE TABLE OF LEADS INTERESTS ***
- $form['fields'][$k]['choices'] = array(
- 0 => array(
- 'text' => 'Skiing',
- 'value' => '1',
- 'isSelected' => false,
- 'price' => false
- ),
- 1 => array(
- 'text' => 'Boating',
- 'value' => '2',
- 'isSelected' => false,
- 'price' => false
- ),
- 2 => array(
- 'text' => 'Hiking',
- 'value' => '3',
- 'isSelected' => false,
- 'price' => false
- )
- );
- }
-
- }
-
-*/
-
+ //echo '<pre>$form: ' . print_r($form, true) . '</pre>';
+ $newCheckbox = new GF_Field_Checkbox();
+ $newCheckbox->label = 'Interest Fields';
+ $newCheckbox->inputName = 'glm_assoc_interest';
+ $newCheckbox->choices = array(
+ 0 => array(
+ 'text' => 'Skiing',
+ 'value' => '1',
+ 'isSelected' => false,
+ 'price' => false
+ ),
+ 1 => array(
+ 'text' => 'Boating',
+ 'value' => '2',
+ 'isSelected' => false,
+ 'price' => false
+ ),
+ 2 => array(
+ 'text' => 'Hiking',
+ 'value' => '3',
+ 'isSelected' => false,
+ 'price' => false
+ )
+ );
+ //echo '<pre>$newCheckbox: ' . print_r($newCheckbox, true) . '</pre>';
+ $form['fields'][] = $newCheckbox;
return $form;
});
-
-// Check all GravityForm submissions to see if they are a form that supplies leads
-add_filter( 'gform_pre_render', function($form) {
-
- // Check for some key field (perhaps hidden) that indicates that the form contains lead information
-
- // Collect the leads data and store it using a data class
-
-});
+add_action( 'gform_after_submission', function( $entry, $form ){
+ echo '<pre>$entry: ' . print_r($entry, true) . '</pre>';
+ echo '<pre>$form: ' . print_r($form, true) . '</pre>';
+ exit;
+}, 10, 2);