Hi,
On my site, I have declared an extra field which is displayed on the article modification form. This field is just there to indicate whether or not an article should appear on the home page of my site. However, when I save a NEW article, the value of the field is not saved in the attribs column of the Content table.
Searching in the code, I found the onContentBeforeSave function at line 191 and located in the file "plugins/system/t4/src/t4/Helper/ExtraField.php" which executes on the onContentBeforeSave event emitted by Joomla. By commenting out the function, my extra field is well saved.
Two questions come to mind:
What is the use of this function? Why do you want to do a json_encode on the attribs field when Joomla does it upstream in the code for us? Indeed, when the function is commented, the value of the field is found in the database in JSON format.
Also, from my understanding of the code for this function, it will never save the new value of the attribs field when it comes to saving a new article. With a new article, the attrib field is necessarily NULL. So the code between lines 199 and 201 (if(!empty($oldAttribs[$name]))...) will never execute and this field will never be able to be updated.
If I open an article that already has a value in the attribs field, we pass in the if and the new value of the field is saved.
At this point, I'm stuck.
Anyone have a solution?
Thank you.
EDIT: Joomla 3.10.3 + T4 System Plugin 2.0.8 + T4 Blank Template 1.1.3