From bd2e25c4ae3066ef193168e380e941673b658342 Mon Sep 17 00:00:00 2001 From: Pratik Joshi Date: Thu, 18 Apr 2013 18:53:33 +0530 Subject: [PATCH] found a bug while runing test case WebTest_Contact_InlineFieldsEditTest : while editing the custom field the form fields have values populated --- CRM/Contact/Form/Inline/CustomData.php | 3 ++- CRM/Contact/Page/Inline/CustomData.php | 12 +++++++++--- .../CRM/Contact/Page/View/CustomDataFieldView.tpl | 2 +- templates/CRM/Contact/Page/View/CustomDataView.tpl | 4 +++- 4 files changed, 15 insertions(+), 6 deletions(-) diff --git a/CRM/Contact/Form/Inline/CustomData.php b/CRM/Contact/Form/Inline/CustomData.php index 6bea43e1a5..f0672a37c4 100644 --- a/CRM/Contact/Form/Inline/CustomData.php +++ b/CRM/Contact/Form/Inline/CustomData.php @@ -62,8 +62,9 @@ class CRM_Contact_Form_Inline_CustomData extends CRM_Contact_Form_Inline { $this->_groupID = CRM_Utils_Request::retrieve('groupID', 'Positive', $this, TRUE, NULL, $_REQUEST); $this->assign('customGroupId', $this->_groupID); $customRecId = CRM_Utils_Request::retrieve('customRecId', 'Positive', $this, FALSE, 1, $_REQUEST); + $cgcount = CRM_Utils_Request::retrieve('cgcount', 'Positive', $this, FALSE, 1, $_REQUEST); $subType = CRM_Contact_BAO_Contact::getContactSubType($this->_contactId, ','); - CRM_Custom_Form_CustomData::preProcess($this, null, $subType, $customRecId, + CRM_Custom_Form_CustomData::preProcess($this, null, $subType, $cgcount, $this->_contactType, $this->_contactId); } diff --git a/CRM/Contact/Page/Inline/CustomData.php b/CRM/Contact/Page/Inline/CustomData.php index a6a150d8d9..204e9bc93c 100644 --- a/CRM/Contact/Page/Inline/CustomData.php +++ b/CRM/Contact/Page/Inline/CustomData.php @@ -53,6 +53,7 @@ class CRM_Contact_Page_Inline_CustomData extends CRM_Core_Page { $contactId = CRM_Utils_Request::retrieve('cid', 'Positive', CRM_Core_DAO::$_nullObject, TRUE, NULL, $_REQUEST); $cgId = CRM_Utils_Request::retrieve('groupID', 'Positive', CRM_Core_DAO::$_nullObject, TRUE, NULL, $_REQUEST); $customRecId = CRM_Utils_Request::retrieve('customRecId', 'Positive', CRM_Core_DAO::$_nullObject, FALSE, 1, $_REQUEST); + $cgcount = CRM_Utils_Request::retrieve('cgcount', 'Positive', CRM_Core_DAO::$_nullObject, FALSE, 1, $_REQUEST); //custom groups Inline $entityType = CRM_Contact_BAO_Contact::getContactType($contactId); @@ -62,8 +63,13 @@ class CRM_Contact_Page_Inline_CustomData extends CRM_Core_Page { ); $details = CRM_Core_BAO_CustomGroup::buildCustomDataView($this, $groupTree); //get the fields of single custom group record - $fields = CRM_Utils_Array::value($customRecId, $details[$cgId]); - + if ($customRecId == 1) { + $fields = reset($details[$cgId]); + } + else { + $fields = CRM_Utils_Array::value($customRecId, $details[$cgId]); + } + $this->assign('cgcount', $cgcount); $this->assign('customRecId', $customRecId); $this->assign('contactId', $contactId); $this->assign('customGroupId', $cgId); @@ -71,7 +77,7 @@ class CRM_Contact_Page_Inline_CustomData extends CRM_Core_Page { // check logged in user permission CRM_Contact_Page_View::checkUserPermission($this, $contactId); - + // finally call parent parent::run(); } diff --git a/templates/CRM/Contact/Page/View/CustomDataFieldView.tpl b/templates/CRM/Contact/Page/View/CustomDataFieldView.tpl index 8122e3325b..dd3364d665 100644 --- a/templates/CRM/Contact/Page/View/CustomDataFieldView.tpl +++ b/templates/CRM/Contact/Page/View/CustomDataFieldView.tpl @@ -23,7 +23,7 @@ | see the CiviCRM license FAQ at http://civicrm.org/licensing | +--------------------------------------------------------------------+ *} -
+
{if $permission EQ 'edit'}
diff --git a/templates/CRM/Contact/Page/View/CustomDataView.tpl b/templates/CRM/Contact/Page/View/CustomDataView.tpl index a89fc7553e..dff13c1544 100644 --- a/templates/CRM/Contact/Page/View/CustomDataView.tpl +++ b/templates/CRM/Contact/Page/View/CustomDataView.tpl @@ -26,6 +26,7 @@ {* Custom Data view mode*} {assign var="customGroupCount" value = 1} {foreach from=$viewCustomData item=customValues key=customGroupId} + {assign var="cgcount" value=1} {assign var="count" value=$customGroupCount%2} {if ($count eq $side) or $skipTitle } {foreach from=$customValues item=cd_edit key=cvID} @@ -37,9 +38,10 @@ {assign var='cvID' value='-1'} {/if}
- {include file="CRM/Contact/Page/View/CustomDataFieldView.tpl" customGroupId=$customGroupId customRecId=$cvID} + {include file="CRM/Contact/Page/View/CustomDataFieldView.tpl" customGroupId=$customGroupId customRecId=$cvID cgcount=$cgcount}
+ {assign var="cgcount" value=$cgcount+1} {/foreach} {/if} {assign var="customGroupCount" value = $customGroupCount+1} -- 2.25.1