From a683acde62a85b517fa962c0b5e5b304323e1411 Mon Sep 17 00:00:00 2001 From: dvdwalker Date: Wed, 24 Feb 2021 17:00:10 -0300 Subject: [PATCH] Fix: Ajax on/off not saving value in DB after updating to version >=12 The issue seams to be that starting in version 12 the "[element]_UPDATE" trigger is called in file core/ajax/objectonoff.php but some properties that are required on $object are not set. Those are (at least for product that is what I use): $object->id $object->table_element $object->fields[$field] The error occurs on the setValueFrom function in core/class/commonobject.class.php file --- htdocs/core/ajax/objectonoff.php | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/htdocs/core/ajax/objectonoff.php b/htdocs/core/ajax/objectonoff.php index ceb221b4870..593f4fa4dbc 100644 --- a/htdocs/core/ajax/objectonoff.php +++ b/htdocs/core/ajax/objectonoff.php @@ -78,5 +78,9 @@ if (($action == 'set') && !empty($id)) { $format = 'int'; + $object->table_element = $tablename; + $object->id = $id; + $object->fields[$field] = array('type' => $format, 'enabled' => 1); + $object->setValueFrom($field, $value, $tablename, $id, $format, '', $user, $triggerkey); }