diff --git a/htdocs/core/ajax/ajaxextrafield.php b/htdocs/core/ajax/ajaxextrafield.php index 012651776f7..de0ea3d79a6 100644 --- a/htdocs/core/ajax/ajaxextrafield.php +++ b/htdocs/core/ajax/ajaxextrafield.php @@ -52,9 +52,15 @@ $search = GETPOST('search', 'restricthtml'); $page = GETPOSTINT('page'); $limit = 10; $offset = (($page - 1) * $limit); - +$element_ref = ''; +if (is_numeric($id)) { + $id = (int) $id; +} else { + $element_ref = $id; + $id = 0; +} // Load object according to $element -$object = fetchObjectByElement($id, $objecttype); +$object = fetchObjectByElement($id, $objecttype, $element_ref); if (empty($object->element)) { httponly_accessforbidden('Failed to get object with fetchObjectByElement(id=' . $id . ', objecttype=' . $objecttype . ')'); }