From 18d88617318e15c7905d246f6b473f6567d34f3f Mon Sep 17 00:00:00 2001 From: Chuck Scott Date: Tue, 19 Dec 2017 14:18:56 -0500 Subject: [PATCH] Fixed display of submitted field type data other than picklist. --- classes/data/dataCustomFields.php | 20 ++++----- setup/commonHooks.php | 50 +++++++++++++++++++---- views/front/customFields/displayForm.html | 2 +- 3 files changed, 54 insertions(+), 18 deletions(-) diff --git a/classes/data/dataCustomFields.php b/classes/data/dataCustomFields.php index 10ca664..344a74c 100644 --- a/classes/data/dataCustomFields.php +++ b/classes/data/dataCustomFields.php @@ -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; diff --git a/setup/commonHooks.php b/setup/commonHooks.php index 8eefe69..1de61a4 100644 --- a/setup/commonHooks.php +++ b/setup/commonHooks.php @@ -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 ); + + diff --git a/views/front/customFields/displayForm.html b/views/front/customFields/displayForm.html index 6bd2fe8..12a1b45 100644 --- a/views/front/customFields/displayForm.html +++ b/views/front/customFields/displayForm.html @@ -4,7 +4,7 @@
{$field.field_prompt}
- +
{/if} -- 2.17.1