mirror of
https://github.com/Combodo/iTop.git
synced 2026-04-21 01:28:47 +02:00
Bug fix: the result of CheckToWrite() was not taken into account (action failed silently) when creating an object using the [+] button inside a form.
SVN:trunk[4056]
This commit is contained in:
@@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -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
|
||||
$('<option/>', { value : data.id }).html(data.name).appendTo('#'+me.id);
|
||||
|
||||
Reference in New Issue
Block a user