diff --git a/application/ui.extkeywidget.class.inc.php b/application/ui.extkeywidget.class.inc.php index 561f1b4b6..a430dface 100644 --- a/application/ui.extkeywidget.class.inc.php +++ b/application/ui.extkeywidget.class.inc.php @@ -505,16 +505,23 @@ EOF */ public function DoCreateObject($oPage) { - $oObj = MetaModel::NewObject($this->sTargetClass); - $aErrors = $oObj->UpdateObjectFromPostedForm($this->iId); - if (count($aErrors) == 0) + try { - $oObj->DBInsert(); - return array('name' => $oObj->GetName(), 'id' => $oObj->GetKey()); + $oObj = MetaModel::NewObject($this->sTargetClass); + $aErrors = $oObj->UpdateObjectFromPostedForm($this->iId); + if (count($aErrors) == 0) + { + $oObj->DBInsert(); + return array('name' => $oObj->GetName(), 'id' => $oObj->GetKey()); + } + else + { + return array('error' => implode(' ', $aErrors), 'id' => 0); + } } - else + catch(Exception $e) { - return array('name' => implode(' ', $aErrors), 'id' => 0); + return array('error' => $e->getMessage(), 'id' => 0); } } diff --git a/js/extkeywidget.js b/js/extkeywidget.js index 4e179a1c8..f61fcd93e 100644 --- a/js/extkeywidget.js +++ b/js/extkeywidget.js @@ -381,7 +381,13 @@ function ExtKeyWidget(id, sTargetClass, sFilter, sTitle, bSelectMode, oWizHelper me.ajax_request = $.post( AddAppContext(GetAbsoluteUrlAppRoot()+'pages/ajax.render.php'), theMap, function(data) { - if (me.bSelectMode) + $('#fstatus_'+me.id).html(''); + if (data.id == 0) + { + $('#label_'+me.id).removeClass('ac_dlg_loading'); + alert(data.error); + } + else if (me.bSelectMode) { // Add the newly created object to the drop-down list and select it $('