diff --git a/application/ui.extkeywidget.class.inc.php b/application/ui.extkeywidget.class.inc.php index 1e71ef6d9..5e3d6350f 100644 --- a/application/ui.extkeywidget.class.inc.php +++ b/application/ui.extkeywidget.class.inc.php @@ -134,7 +134,7 @@ class UIExtKeyWidget { $sWizHelper = 'oWizardHelper'.$sFormPrefix; } - $sWizHelperJSON = $sWizHelper.'.ToJSON()'; + $sWizHelperJSON = $sWizHelper.'.UpdateWizardToJSON()'; $sJSSearchMode = 'false'; } if (is_null($oAllowedValues)) diff --git a/application/ui.linkswidget.class.inc.php b/application/ui.linkswidget.class.inc.php index 82da8745f..027ecf361 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,10 +130,11 @@ 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 - $oNewLinkObj->Set($this->m_sExtKeyToMe, $oCurrentObj); // Setting the extkey with the object alsoo fills the related external fields + $oNewLinkObj->Set($this->m_sExtKeyToMe, $oCurrentObj); // Setting the extkey with the object also fills the related external fields $sNameSuffix = "]"; // To make a tabular form $aArgs['prefix'] = $sPrefix; $aArgs['wizHelper'] = "oWizardHelper{$this->m_iInputId}_".(-$linkObjOrId); @@ -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