From 607466e9285a3033af1145d931341773befd89fe Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E2=80=9Cankush=5Fm=E2=80=9D?= Date: Wed, 27 Nov 2019 18:49:09 +0530 Subject: [PATCH] Bug #153557 fix: Frontend>> Removed record from UCM subform is still visible if user check it from edit mode --- site/helpers/tjfields.php | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/site/helpers/tjfields.php b/site/helpers/tjfields.php index a5bb3ad7..5c72b9a4 100644 --- a/site/helpers/tjfields.php +++ b/site/helpers/tjfields.php @@ -277,16 +277,19 @@ public function saveFieldsValue($data) array_pop($ucmSubformClientTmp); $ucmSubformClient = 'com_tjucm.' . implode('_', $ucmSubformClientTmp); - // Load UCM models + // Load UCM itemform model JLoader::import('components.com_tjucm.models.itemform', JPATH_SITE); - JLoader::import('components.com_tjucm.models.items', JPATH_SITE); // Get all the records which were previously stored for the ucmsubform field in parent form - $tjucmItemsModel = JModelLegacy::getInstance('Items', 'TjucmModel', array('ignore_request' => true)); - $tjucmItemsModel->setState('parent_id', TJUCM_PARENT_CONTENT_ID); - $tjucmItemsModel->setState('ucm.client', $ucmSubformClient); - $ucmSubformRecords = $tjucmItemsModel->getItems(); - $ucmSubformRecordIds = (!empty($ucmSubformRecords)) ? array_column($ucmSubformRecords, 'id') : array(); + $db = JFactory::getDbo(); + $query = $db->getQuery(true); + $query->select('id'); + $query->from($db->quoteName('#__tj_ucm_data')); + $query->where($db->quoteName('parent_id') . '=' . TJUCM_PARENT_CONTENT_ID); + $query->where($db->quoteName('client') . '=' . $db->quote($ucmSubformClient)); + $db->setQuery($query); + $ucmSubformRecordIds = $db->loadColumn(); + $ucmSubformRecordIds = (!empty($ucmSubformRecordIds)) ? $ucmSubformRecordIds : array(); $this->saveSingleValuedFieldData($ucmSubformClient, TJUCM_PARENT_CLIENT, TJUCM_PARENT_CONTENT_ID, $field->id, $fieldStoredValues);