Fix front hooks
authorSteve Sutton <steve@gaslightmedia.com>
Tue, 5 Jul 2016 20:08:14 +0000 (16:08 -0400)
committerSteve Sutton <steve@gaslightmedia.com>
Tue, 5 Jul 2016 20:08:14 +0000 (16:08 -0400)
adding to form to test what can be done.

models/admin/management/leads.php
setup/frontHooks.php

index 123238f..0e61bd3 100644 (file)
@@ -115,6 +115,8 @@ class GlmMembersAdmin_management_leads // extends GlmDataLeadsManagement
     public function modelAction($actionData = false)
     {
 
+        //$leadForms = GFAPI::get_forms();
+        //echo '<pre>$leadForms: ' . print_r($leadForms, true) . '</pre>';
 
         // Compile template data
         $templateData = array(
index 00b947a..6bac904 100644 (file)
 // 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);