Thanks for finxing the warning.
Regarding the disapperaing issue I did some more research using J!Dump. The $data object is filled corretly after a validation error thanks to your last commit.
However, in 2 out of 3 possible entry types in the tag element the line 87 in the tags element plugin file 'tags.php'.
Code:
$tmp = $this->_getOptions($data, $repeatCounter, true);
does not return all tags in the correct format after a validaiton error.
The 3 entry types being:
- a new entry using a tag which already exists in jos_tags and in the table created for the tag element, e.g. table_repeat_tag
- a new entry using a tag which already exists in jos_tags, but NOT in table_repeat_tag
- a new entry which neither exits in jos_tags nor in table_repeat_tag
In case 1 everything works fine after a validation error - all tags entered before are shown.
In case 2 and 3 the new entry is not part of $tmp and therefore not displayed. IMHO, reason for this is the way the function _getOptions respectivley _getOptionsVals translates $data into text and value. The crucial line of code seems to be line 559 in the databasejoin element plugin file 'databasejoin.php':
Code:
$this->optionVals[$sqlKey] = $db->loadObjectList();
In case 2 '$sqlKey' would be:
Code:
SELECT DISTINCT(t.id) AS value,`title` AS text
FROM `table_repeat_tag` AS `table_repeat_tag`
LEFT JOIN #__tags AS t ON t.id = `table_repeat_tag`.`tag`
WHERE `table_repeat_tag`.`tag` IN (0)
The part causing the problem is the 0 in the WHERE clause - 0 since there is no entry in jos_tags for the new entry.
In case 3 instead of the 0 the SQL query would contain the ID of the tag in jos_tags, but the SQL query would return null since no record in table_repeat_tag has this value in the column 'tag' yet.
So for case 2 and 3 we probably need another way of returning the text and value for new entries instead of using '_getOptoins'.
Maybe we could use 'this->getValue' to check if there are any entries in the tag element belonging to case 2 or 3. Case 2 could be then solved by just stripping the prefix '#fabrik#' from the value of the new entry. Case 3 would need an SQL query on the jos_tags table.
I dont have enough Fabrik PHP coding experience to make this approach work with acceptable effort. Hopefully someone can use my research to solve this issue.
I also tried to use the code hugh deleted in his last commit - but the variable '$defaultLabels' returns the ID of the tag in jos_tags in case 2 and '#fabrik#newEntry' in case 3 - which both wont make the new entry show up after an validation error.
Chris