From b7a9b340b87226e97739f6f6cafda63c8c15d16b Mon Sep 17 00:00:00 2001 From: Denis Flaven Date: Thu, 22 Mar 2012 09:11:45 +0000 Subject: [PATCH] Bug fix: support [+] button inside linkedsets.. with constraints SVN:1.2[1912] --- application/ui.linkswidget.class.inc.php | 37 ++++++++++++++++++++++++ 1 file changed, 37 insertions(+) diff --git a/application/ui.linkswidget.class.inc.php b/application/ui.linkswidget.class.inc.php index 0c5bc0842..db93f0502 100644 --- a/application/ui.linkswidget.class.inc.php +++ b/application/ui.linkswidget.class.inc.php @@ -108,6 +108,7 @@ class UILinksWidget if(is_object($linkObjOrId)) { $key = $linkObjOrId->GetKey(); + $iRemoteObjKey = $linkObjOrId->Get($this->m_sExtKeyToRemote); $sPrefix .= "[$key]["; $sNameSuffix = "]"; // To make a tabular form $aArgs['prefix'] = $sPrefix; @@ -129,6 +130,7 @@ class UILinksWidget { // form for creating a new record $sPrefix .= "[$linkObjOrId]["; + $iRemoteObjKey = -$linkObjOrId; $oNewLinkObj = MetaModel::NewObject($this->m_sLinkedClass); $oRemoteObj = MetaModel::GetObject($this->m_sRemoteClass, -$linkObjOrId); $oNewLinkObj->Set($this->m_sExtKeyToRemote, $oRemoteObj); // Setting the extkey with the object alsoo fills the related external fields @@ -148,8 +150,38 @@ class UILinksWidget $aFieldsMap[$sFieldCode] = $sFieldId; } $sState = ''; + $oP->add_script( +<<MakeID($sPrefix.$this->m_sExtKeyToMe); + $aFieldsMap[$this->m_sExtKeyToMe] = $sExtKeyToMeId; + $aRow['form::checkbox'] .= "GetKey()."\">"; + + $sExtKeyToRemoteId = $this->MakeID($sPrefix.$this->m_sExtKeyToRemote); + $aFieldsMap[$this->m_sExtKeyToRemote] = $sExtKeyToRemoteId; + $aRow['form::checkbox'] .= ""; + $iFieldsCount = count($aFieldsMap); $sJsonFieldsMap = json_encode($aFieldsMap); @@ -167,6 +199,11 @@ EOF } return $aRow; } + + protected function MakeID($sName) + { + return str_replace(array('[', ']'), '_', $sName); + } /** * Display one row of the whole form