From: deb.monish Date: Fri, 22 Jul 2016 14:18:12 +0000 (+0530) Subject: store/fetch the submitted data to/form cache X-Git-Url: https://vcs.fsf.org/?a=commitdiff_plain;h=29a1df580e7df9eb26563cd26248a76ef9879b40;p=civicrm-core.git store/fetch the submitted data to/form cache --- diff --git a/CRM/Core/BAO/CustomGroup.php b/CRM/Core/BAO/CustomGroup.php index 86ae03888c..0e3574b66e 100644 --- a/CRM/Core/BAO/CustomGroup.php +++ b/CRM/Core/BAO/CustomGroup.php @@ -1832,10 +1832,12 @@ SELECT IF( EXISTS(SELECT name FROM civicrm_contact_type WHERE name like %1), 1, $formattedGroupTree = array(); $uploadNames = $formValues = array(); - // JSON encoded submitted form values passed via URL - $submittedValues = CRM_Utils_Request::retrieve('post', 'String'); - if (!empty($submittedValues)) { - $submittedValues = json_decode($submittedValues, TRUE); + // retrieve qf key from url + $qfKey = CRM_Utils_Request::retrieve('qf', 'String'); + + // fetch submitted custom field values later use to set as a default values + if ($qfKey) { + $submittedValues = CRM_Core_BAO_Cache::getItem('custom data', $qfKey); } foreach ($groupTree as $key => $value) { @@ -1863,12 +1865,12 @@ SELECT IF( EXISTS(SELECT name FROM civicrm_contact_type WHERE name like %1), 1, // add field information foreach ($value['fields'] as $k => $properties) { $properties['element_name'] = "custom_{$k}_-{$groupCount}"; - if (isset($submittedValues[$properties['element_name']])) { - $properties['element_value'] = $submittedValues[$properties['element_name']]; - } - elseif ($value = CRM_Utils_Request::retrieve($properties['element_name'], 'String', $form, FALSE, NULL, 'POST')) { + if ($value = CRM_Utils_Request::retrieve($properties['element_name'], 'String', $form, FALSE, NULL, 'POST')) { $formValues[$properties['element_name']] = $value; } + elseif (isset($submittedValues[$properties['element_name']])) { + $properties['element_value'] = $submittedValues[$properties['element_name']]; + } if (isset($properties['customValue']) && !CRM_Utils_System::isNull($properties['customValue']) && !isset($properties['element_value']) @@ -1892,7 +1894,9 @@ SELECT IF( EXISTS(SELECT name FROM civicrm_contact_type WHERE name like %1), 1, if ($form) { if (count($formValues)) { - $form->assign('submittedValues', json_encode($formValues)); + $qf = $form->get('qfKey'); + $form->assign('qfKey', $qf); + CRM_Core_BAO_Cache::setItem($formValues, 'custom data', $qf); } // hack for field type File diff --git a/templates/CRM/common/customData.tpl b/templates/CRM/common/customData.tpl index 5ba9f63567..e4bbcf2ace 100644 --- a/templates/CRM/common/customData.tpl +++ b/templates/CRM/common/customData.tpl @@ -54,8 +54,8 @@ {if $entityID} dataUrl += '&entityID=' + '{$entityID}'; {/if} - {if $submittedValues} - dataUrl += '&post=' + '{$submittedValues}'; + {if $qfKey} + dataUrl += '&qf=' + '{$qfKey}'; {/if} {literal}