CRM-13992_temp_fix : fix for comment #comment-58624
authorPratik Joshi <pratik.joshi@webaccess.co.in>
Tue, 25 Mar 2014 12:49:05 +0000 (18:19 +0530)
committerPratik Joshi <pratik.joshi@webaccess.co.in>
Tue, 25 Mar 2014 12:49:05 +0000 (18:19 +0530)
CRM/Contact/Form/CustomData.php
templates/CRM/Contact/Form/CustomData.tpl

index a3e9feffd1f01dbd746d6f8d13e07410b3926df7..c8e9cf4cd177ed8316e117fc1536a0a7fc354df4 100644 (file)
@@ -132,6 +132,11 @@ class CRM_Contact_Form_CustomData extends CRM_Core_Form {
         $this->_groupID = CRM_Utils_Request::retrieve('groupID', 'Positive', $this);
         $this->_tableID = $this->_entityId;
         $this->_copyValueId = CRM_Utils_Request::retrieve('copyValueId', 'Positive', $this);
+        $backUrl = CRM_Core_Session::singleton()->readUserContext();
+        $this->assign('backUrl', $backUrl);
+        if (!empty($_POST['hidden_custom'])) {
+          $this->assign('postedInfo', TRUE);
+        }
       }
       return;
     }
index a0cbf755dc52bb333e1769537078c57ead805d6c..86929ccb00ceb7a8fb66538106c245c7469f352f 100644 (file)
@@ -24,7 +24,7 @@
  +--------------------------------------------------------------------+
 *}
 {* this template is used for building tabbed custom data *}
-{if $cdType }
+{if $cdType || $postedInfo}
    {include file="CRM/Custom/Form/CustomData.tpl"}
    {if $multiRecordDisplay eq 'single'}
      <div class="html-adjust">{$form.buttons.html}</div>
      <script type='text/javascript'>
        cj(function($) {
          $('#custom-record-dialog .crm-container-snippet #CustomData').validate(CRM.validate.params);
+         var formOptions = {
+           success:       checkResponse  // post-submit callback
+         };
+
+         //binding the callback to snippet profile form
+         $('.crm-container-snippet #CustomData').ajaxForm(formOptions);
        });
+
+     // post-submit callback
+     function checkResponse(responseText, statusText, xhr, $form) {
+       //if there is any form error show the dialog
+       //else redirect to post url
+       if (!cj(responseText).find('.crm-error').html()) {
+         window.location.href = '{/literal}{$backUrl}{literal}';
+       }
+     }
      </script>
      {/literal}
    {/if}