/** * Get the form to create a new object of the 'target' class */ public function GetObjectCreationForm(WebPage $oPage, $oCurrObject) { // Set all the default values in an object and clone this "default" object $oNewObj = MetaModel::NewObject($this->sTargetClass); // 1st - set context values $oAppContext = new ApplicationContext(); $oAppContext->InitObjectFromContext($oNewObj); // 2nd set the default values from the constraint on the external key... if any if ($oCurrObject != null && $this->sAttCode != '') { $oAttDef = MetaModel::GetAttributeDef(get_class($oCurrObject), $this->sAttCode); $aParams = array('this' => $oCurrObject); $oSet = $oAttDef->GetAllowedValuesAsObjectSet($aParams); $aConsts = $oSet->ListConstantFields(); $sClassAlias = $oSet->GetFilter()->GetClassAlias(); if (isset($aConsts[$sClassAlias])) { foreach ($aConsts[$sClassAlias] as $sAttCode => $value) { $oNewObj->Set($sAttCode, $value); } } } // 3rd - set values from the page argument 'default' $oNewObj->UpdateObjectFromArg('default'); $sDialogTitle = ''; $oPage->add('<div id="ac_create_' . $this->iId . '"><div class="wizContainer" style="vertical-align:top;"><div id="dcr_' . $this->iId . '">'); $oPage->add("<h1>" . MetaModel::GetClassIcon($this->sTargetClass) . " " . Dict::Format('UI:CreationTitle_Class', MetaModel::GetName($this->sTargetClass)) . "</h1>\n"); cmdbAbstractObject::DisplayCreationForm($oPage, $this->sTargetClass, $oNewObj, array(), array('formPrefix' => $this->iId, 'noRelations' => true)); $oPage->add('</div></div></div>'); // $oPage->add_ready_script("\$('#ac_create_$this->iId').dialog({ width: $(window).width()*0.8, height: 'auto', autoOpen: false, modal: true, title: '$sDialogTitle'});\n"); $oPage->add_ready_script("\$('#ac_create_{$this->iId}').dialog({ width: 'auto', height: 'auto', maxHeight: \$(window).height() - 50, autoOpen: false, modal: true, title: '{$sDialogTitle}'});\n"); $oPage->add_ready_script("\$('#dcr_{$this->iId} form').removeAttr('onsubmit');"); $oPage->add_ready_script("\$('#dcr_{$this->iId} form').bind('submit.uilinksWizard', oACWidget_{$this->iId}.DoCreateObject);"); }
$sRealClass = $aKeys[0]; } } else { $sRealClass = $sClass; } if (!empty($sRealClass)) { // Display the creation form $sClassLabel = MetaModel::GetName($sRealClass); // Note: some code has been duplicated to the case 'apply_new' when a data integrity issue has been found $oP->set_title(Dict::Format('UI:CreationPageTitle_Class', $sClassLabel)); $oP->add("<h1>" . MetaModel::GetClassIcon($sRealClass) . " " . Dict::Format('UI:CreationTitle_Class', $sClassLabel) . "</h1>\n"); $oP->add("<div class=\"wizContainer\">\n"); // Set all the default values in an object and clone this "default" object $oObjToClone = MetaModel::NewObject($sRealClass); // 1st - set context values $oAppContext->InitObjectFromContext($oObjToClone); // 2nd - set values from the page argument 'default' $oObjToClone->UpdateObjectFromArg('default'); cmdbAbstractObject::DisplayCreationForm($oP, $sRealClass, $oObjToClone, array()); $oP->add("</div>\n"); } else { // Select the derived class to create $sClassLabel = MetaModel::GetName($sClass); $oP->add("<h1>" . MetaModel::GetClassIcon($sClass) . " " . Dict::Format('UI:CreationTitle_Class', $sClassLabel) . "</h1>\n"); $oP->add("<div class=\"wizContainer\">\n"); $oP->add('<form>'); $oP->add('<p>' . Dict::Format('UI:SelectTheTypeOf_Class_ToCreate', $sClassLabel)); $aDefaults = utils::ReadParam('default', array(), false, 'raw_data'); $oP->add($oAppContext->GetForForm()); $oP->add("<input type=\"hidden\" name=\"checkSubclass\" value=\"0\">\n"); $oP->add("<input type=\"hidden\" name=\"state\" value=\"{$sStateCode}\">\n");