diff --git a/site/helpers/tjfields.php b/site/helpers/tjfields.php index 5c72b9a4..7de16977 100644 --- a/site/helpers/tjfields.php +++ b/site/helpers/tjfields.php @@ -483,7 +483,9 @@ private function saveSingleValuedFieldData($fieldValue, $client, $contentId, $fi } JLoader::import('components.com_tjfields.tables.fieldsvalue', JPATH_ADMINISTRATOR); + JLoader::import('components.com_tjfields.tables.option', JPATH_ADMINISTRATOR); $fieldsValueTable = JTable::getInstance('FieldsValue', 'TjfieldsTable', array('dbo', JFactory::getDbo())); + $fieldOptionTable = JTable::getInstance('Option', 'TjfieldsTable', array('dbo', JFactory::getDbo())); // Set currently logged in users id as user_id $fieldsValueTable->user_id = JFactory::getUser()->id; @@ -497,6 +499,12 @@ private function saveSingleValuedFieldData($fieldValue, $client, $contentId, $fi if ($fieldValue != '') { $fieldsValueTable->value = $fieldValue; + $fieldOptionTable->load(array('field_id' => $fieldId, 'value' => $fieldValue)); + + if ($fieldOptionTable->id) + { + $fieldsValueTable->option_id = $fieldOptionTable->id; + } if ($fieldsValueTable->store()) { @@ -519,6 +527,13 @@ private function saveSingleValuedFieldData($fieldValue, $client, $contentId, $fi $fieldsValueTable->value = $fieldValue; $fieldsValueTable->client = $client; + $fieldOptionTable->load(array('field_id' => $fieldId, 'value' => $fieldValue)); + + if ($fieldOptionTable->id) + { + $fieldsValueTable->option_id = $fieldOptionTable->id; + } + if ($fieldsValueTable->store()) { return true;