N°2044: Enable Search form prefill when adding objects to 1:n

This commit is contained in:
Stephen Abello
2019-06-04 11:18:30 +02:00
parent 179c774ba8
commit 7c1290f684
2 changed files with 14 additions and 3 deletions

View File

@@ -286,11 +286,13 @@ class UILinksWidgetDirect
* @param DBObject $oCurrentObj
* @param $aAlreadyLinked
*
* @param array $aPrefillFormParam
*
* @throws \CoreException
* @throws \Exception
* @throws \MissingQueryArgument
* @throws \OQLException
*/
public function GetObjectsSelectionDlg($oPage, $oCurrentObj, $aAlreadyLinked)
public function GetObjectsSelectionDlg($oPage, $oCurrentObj, $aAlreadyLinked, $aPrefillFormParam = array())
{
$sHtml = "<div class=\"wizContainer\" style=\"vertical-align:top;\">\n";
@@ -333,6 +335,7 @@ class UILinksWidgetDirect
$aArgs = array_merge($oCurrentObj->ToArgs('this'), $oFilter->GetInternalParams());
$oFilter->SetInternalParams($aArgs);
$oCurrentObj->PrefillForm('search', $aPrefillFormParam);
}
$oBlock = new DisplayBlock($oFilter, 'search', false);
$sHtml .= $oBlock->GetDisplay($oPage, "SearchFormToAdd_{$this->sInputid}",

View File

@@ -382,8 +382,16 @@ try
$iInputId = utils::ReadParam('iInputId', '');
$iCurrObjectId = utils::ReadParam('iObjId', 0);
$oPage->SetContentType('text/html');
$oAppContext = new ApplicationContext();
$aPrefillFormParam = array( 'user' => $_SESSION["auth_user"],
'context' => $oAppContext->GetAsHash(),
'att_code' => $sAttCode,
'origin' => 'console',
'source_obj' => $oObj,
);
$aPrefillFormParam['dest_class'] = ($oObj === null ? '' : $oObj->Get($sAttCode)->GetClass());
$oWidget = new UILinksWidgetDirect($sClass, $sAttCode, $iInputId);
$oWidget->GetObjectsSelectionDlg($oPage, $oObj, $aAlreadyLinked);
$oWidget->GetObjectsSelectionDlg($oPage, $oObj, $aAlreadyLinked, $aPrefillFormParam);
break;
// ui.linksdirectwidget