From: jitendrapurohit Date: Thu, 16 Oct 2014 09:51:29 +0000 (+0530) Subject: CRM-15447 X-Git-Url: https://vcs.fsf.org/?a=commitdiff_plain;h=9382624d3bd12a43285a1e72908b3f99925def36;p=civicrm-core.git CRM-15447 --- diff --git a/CRM/Custom/Form/Group.php b/CRM/Custom/Form/Group.php index 940268bad2..79f23df779 100644 --- a/CRM/Custom/Form/Group.php +++ b/CRM/Custom/Form/Group.php @@ -546,16 +546,22 @@ class CRM_Custom_Form_Group extends CRM_Core_Form { static function getFormattedList(&$list) { $relName = array(); - foreach ($list as $k => $v) { - $key = substr($k, 0, strpos($k, '_')); + foreach ($list as $listItemKey => $itemValue) { + // Extract the relationship ID. + $key = substr($listItemKey, 0, strpos($listItemKey, '_')); if (isset($list["{$key}_b_a"])) { + $relName["$key"] = $list["{$key}_a_b"]; + // Are the two labels different? if ($list["{$key}_a_b"] != $list["{$key}_b_a"]) { $relName["$key"] = $list["{$key}_a_b"] . ' / ' . $list["{$key}_b_a"]; } unset($list["{$key}_b_a"]); + unset($list["{$key}_a_b"]); } else { + // If no '_b_a' label exists save the '_a_b' one and unset it from the list $relName["{$key}"] = $list["{$key}_a_b"]; + unset($list["{$key}_a_b"]); } } return $relName;