Fix #yogosha5877

This commit is contained in:
Laurent Destailleur
2021-04-24 21:02:48 +02:00
parent b2c2c55214
commit ac68599fab

View File

@@ -208,12 +208,17 @@ class MyModuleApi extends DolibarrApi
if (!DolibarrApiAccess::$user->rights->mymodule->write) {
throw new RestException(401);
}
// Check mandatory fields
$result = $this->_validate($request_data);
foreach ($request_data as $field => $value) {
$this->myobject->$field = $value;
}
// Clean data
// $this->myobject->abc = checkVal($this->myobject->abc, 'alphanohtml');
if ($this->myobject->create(DolibarrApiAccess::$user)<0) {
throw new RestException(500, "Error creating MyObject", array_merge(array($this->myobject->error), $this->myobject->errors));
}
@@ -253,6 +258,9 @@ class MyModuleApi extends DolibarrApi
$this->myobject->$field = $value;
}
// Clean data
// $this->myobject->abc = checkVal($this->myobject->abc, 'alphanohtml');
if ($this->myobject->update(DolibarrApiAccess::$user, false) > 0) {
return $this->get($id);
} else {