Fixed display of submitted field type data other than picklist.
authorChuck Scott <cscott@gaslightmedia.com>
Tue, 19 Dec 2017 19:18:56 +0000 (14:18 -0500)
committerChuck Scott <cscott@gaslightmedia.com>
Tue, 19 Dec 2017 19:18:56 +0000 (14:18 -0500)
classes/data/dataCustomFields.php
setup/commonHooks.php
views/front/customFields/displayForm.html

index 10ca664..344a74c 100644 (file)
@@ -245,7 +245,7 @@ class GlmDataFieldsCustomFields extends GlmDataAbstract
                 
                 // Get stored data for the current field 
                 $customFieldData = $CustomFieldData->getEntry($r['id'], 'field_id', "T.record_id = ".$this->recordId);
-                
+
                 // Place the save field data into the current result
                 $r = array_merge($r, array(
                     'text_data'     => $customFieldData['text_data'],
@@ -260,11 +260,11 @@ class GlmDataFieldsCustomFields extends GlmDataAbstract
                     
                     case 'text':
                     case 'textarea':
-                        $r['stored'] = $customFieldData['text_data'];
+                        $r['stored'] = $r['text_data'];
                         break;
                     
                     case 'checkbox':
-                        $r['stored'] = ($customFieldData['checkbox_data'] ? 'Yes' : 'No');
+                        $r['stored'] = ($r['checkbox_data'] ? 'Yes' : 'No');
                         break;
                         
                     case 'picklist':
@@ -277,30 +277,30 @@ class GlmDataFieldsCustomFields extends GlmDataAbstract
                                 if ($optVal['option_value'] == $customFieldData['text_data']) {
                                     $val = true;
                                     $name = 'Yes';
+                                    $r['stored'] = $optVal['option_value'];
+                                    $r['option_text'] = $optVal['option_text'];
                                 }
                                 $r['options'][$optKey]['option_default']['value'] = $val;
                                 $r['options'][$optKey]['option_default']['name'] = $name;
                             }
                         }
                         
-                        $r['stored'] = $optVal['stored'] = $csutomFieldData['text_data'];
-                        
                         break;
                     
                     case 'integer':
-                        $r['stored'] = $customFieldData['integer_data'];
+                        $r['stored'] = $r['integer_data'];
                         break;
                         
                     case 'float':
-                        $r['stored'] = $customFieldData['float_data'];
+                        $r['stored'] = $r['float_data'];
                         break;
                         
                 }
 
-ini_set ( log_errors_max_len, 8192 );
-trigger_error('Stored Data: '.print_r($r,1), E_USER_NOTICE);                
-                
             }
+            
+ini_set(log_errors_max_len,4096);
+trigger_error('Form Fields: '.print_r($r, 1), E_USER_NOTICE);
         
         }
         return $r;
index 8eefe69..1de61a4 100644 (file)
@@ -83,8 +83,8 @@ add_filter( 'glm-members-customfields-plugin-active', function( $active ){
 /**
  * Does the specified Form ID have any input fields
  *
- * @param $content string Default state (supply false). This will be overridden if result is true.
- * @param $fid string Unique ID of form
+ * @param $content  string  Default state (supply false). This will be overridden if result is true.
+ * @param $fid      string  Unique ID of form
  *
  * returns an array with status and HTML for editing the form.
  */
@@ -161,11 +161,15 @@ add_filter( 'glm-members-customfields-form-submit', function( $content, $fid, $r
 
 /**
  * Store data from a call to the "glm-members-customfields-form-submit" filter
+ * 
+ * NOTE: The glm-members-customfields-form-submit filter above can store data for a form submission in one 
+ * call. This filter is for situations where there may need to be additional processing between form submission
+ * and storage.
  *
- * @param $content string Any supplied content. Form will be appended to this
- * @param $fid string Unique ID of form
- * @param $recordId integer ID for instance of this form (generally the ID of the associated record) - Required
- * @param $formData array Copy of the array returned by the "glm-members-customfields-form-submit" filter.
+ * @param $content      string  Any supplied content. Form will be appended to this
+ * @param $fid          string  Unique ID of form
+ * @param $recordId     integer ID for instance of this form (generally the ID of the associated record) - Required
+ * @param $formData     array   Copy of the array returned by the "glm-members-customfields-form-submit" filter.
  *
  * returns an array with status and HTML for editing the form.
  */
@@ -184,6 +188,38 @@ add_filter( 'glm-members-customfields-form-store', function( $content, $fid, $re
 
 }, 10, 4 );
 
-
+/**
+ * Recall data for a form stored with a specific record ID
+ *
+ * @param $content          string  Any supplied content. Form will be appended to this
+ * @param $fid              string  Unique ID of form
+ * @param $recordId         integer ID for instance of this form (generally the ID of the associated record) - Required
+ * @param $priorityDisplay  boolean Display only priority fields flag 
+ *      Note that fields with a cost value are always considered to be priority.
+ *
+ * returns an array with HTML for displaying the results and an array of data that may be used for custom
+ * display.
+ */
+add_filter( 'glm-members-customfields-form-data-recall', function( $content, $fid, $recordId = 0, $priorityDisplay = false ){
+    
+    if (GLM_MEMBERS_PLUGIN_FRONT_DEBUG) {
+        trigger_error('Custom Fields Filter Called: glm-members-customfields-form-data-recall', E_USER_NOTICE);
+    }
+    
+    require_once GLM_MEMBERS_CUSTOMFIELDS_PLUGIN_CLASS_PATH.'/data/dataCustomField.php';
+    $CustomFields = new GlmCustomFields($this->wpdb, $this->config);
+    
+    $form = $CustomFieldSupport->getFormWithData($fid, $recordId, $priorityDisplay);
+    
+ini_set(log_errors_max_len, 5192);
+trigger_error('Form Data Recall: '.print_r($form, 1), E_USER_NOTICE);
+    
+    // Consider using a shortcode to build the HTML 
+    
+    return $content;
+    
+}, 10, 4 );
+    
+        
 
 
index 6bd2fe8..12a1b45 100644 (file)
@@ -4,7 +4,7 @@
                         <div class="glm-row">
                             <div class="glm-small-12 glm-large-12 glm-columns glm-nowrap{if $field.required.value} glm-required{/if}">{$field.field_prompt}</div>
                             <div class="glm-small-12 glm-large-12 glm-columns{if $field.field_fail} glm-fail{/if}">
-                              <input id="glmCustomFormField_{$field.id}" type="text" name="glmCustomFormField_{$field.id}" value=""{if $field.required.value} required{/if}>
+                              <input id="glmCustomFormField_{$field.id}" type="text" name="glmCustomFormField_{$field.id}" value="{$field.text_data}"{if $field.required.value} required{/if}>
                             </div>
                         </div>
     {/if}