Can someone explain me why in the save method of the AdminModel class, there is the creation of a new $newTags property on the $table?

How this new property is used? How is it handled later on by the JTable, especially by the store() method?

/libraries/src/MVC/Model/AdminModel.php #line ~1146

public function save($data)
    $dispatcher = \JEventDispatcher::getInstance();
    $table      = $this->getTable();
    $context    = $this->option . '.' . $this->name;

    if (!empty($data['tags']) && $data['tags'][0] != '')
        $table->newTags = $data['tags'];

I am asking because under certain conditions, using the my model's save() method, I end up with a database error saying that there is no field newTags in my table.

  • Do I have to do something in my own model's save() method to deal with this $newTags?

  • Or do I need to include anything else in my own table class?

  • do you use Joomla! tags for your table? Do you use the term "tags" in your table? – Sven Bluege Feb 2 '18 at 8:24
  • yes I do use Joomla! tags and I have "tags" in my table. Is this what is causing my issues? – FFrewin Feb 2 '18 at 10:14
  • I don't think so. For some reason, the field newTags is send to the database. This should not happen. From my point of view, it is used to fill the tags field. Recommend to check the implementation for tags in com_content. Do you start implementing that tag stuff? If so, you might have a look at those observers for tags. – Sven Bluege Feb 2 '18 at 11:12
  • I have already implemented it and in my item's edit form everything works. I save tags to t5eqt_contentitem_tag_map and I retrieve them fine. My problem is when I call my item model save function from the items list - e.g. changing/toggling state of the item. This somehow ends up with that extra $newTags on my table which produces that error. So that's why I ask what's the deal with this $newTags property that gets created at that point. I don't understand why it is needed, if my data contain already $tags and how it is treated later on. I don't have problem when saving on my item's form. – FFrewin Feb 2 '18 at 11:51
  • @SvenBluege My assumption is that at some point the $newTags should be merged with $Tags - but still no real clue on the case. – FFrewin Feb 2 '18 at 11:52

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.