From 19e5c7f7053cc5e73a28e765c59e723db4a6e537 Mon Sep 17 00:00:00 2001 From: Eileen McNaughton Date: Tue, 17 Mar 2015 00:26:44 +1300 Subject: [PATCH] CRM-16055 fix form to work correctly on update action --- CRM/Contact/Form/Relationship.php | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/CRM/Contact/Form/Relationship.php b/CRM/Contact/Form/Relationship.php index 309abd07dd..684ce7e804 100644 --- a/CRM/Contact/Form/Relationship.php +++ b/CRM/Contact/Form/Relationship.php @@ -404,8 +404,17 @@ class CRM_Contact_Form_Relationship extends CRM_Core_Form { // Update mode (always single) if ($this->_action & CRM_Core_Action::UPDATE) { + $params['id'] = $this->_relationshipId; $ids['relationship'] = $this->_relationshipId; $relation = CRM_Contact_BAO_Relationship::getRelationshipByID($this->_relationshipId); + if ($relation->contact_id_a == $this->_contactId) { + $params['contact_id_a'] = $this->_contactId; + $params['contact_id_b'] = array($params['related_contact_id']); + } + else { + $params['contact_id_b'] = $this->_contactId; + $params['contact_id_a'] = array($params['related_contact_id']); + } $ids['contactTarget'] = ($relation->contact_id_a == $this->_contactId) ? $relation->contact_id_b : $relation->contact_id_a; // @todo this belongs in the BAO. @@ -436,7 +445,7 @@ class CRM_Contact_Form_Relationship extends CRM_Core_Form { // Save relationships $outcome = CRM_Contact_BAO_Relationship::createMultiple($params, $relationshipTypeParts[1]); - list($valid, $invalid, $duplicate, $saved, $relationshipIds) = $outcome; + $relationshipIds = $outcome['relationship_ids']; $this->setMessage($outcome); // if this is called from case view, -- 2.25.1