Skip to content

Commit

Permalink
Bug #153557 fix: Frontend>> Removed record from UCM subform is still …
Browse files Browse the repository at this point in the history
…visible if user check it from edit mode
  • Loading branch information
ankush-maherwal committed Nov 27, 2019
1 parent 39fb1c9 commit 607466e
Showing 1 changed file with 10 additions and 7 deletions.
17 changes: 10 additions & 7 deletions site/helpers/tjfields.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand Down

0 comments on commit 607466e

Please sign in to comment.