I'm using tags in my components. Hm, well - I would like to use them ;-)
This is my form-declaration for tags:
<field name = "tags"
type = "tag"
label = "JTAG"
description = "JTAG_DESC"
class = "inputbox span12 small"
multiple = "true" />
This is my getItem in my model:
/**
* getItem function.
*
* @access public
* @param mixed $pk (default: null)
* @return void
*/
public function getItem($pk = null)
{
if ($item = parent::getItem($pk))
{
// Convert the metadata field to an array.
$registry = new JRegistry;
if(isset($item->metadata))
{
$registry->loadString($item->metadata);
$item->metadata = $registry->toArray();
}
if (!empty($item->id))
{
$item->tags = new JHelperTags;
$item->tags->getTagIds($item->id, 'com_bestia.goal');
$item->metadata['tags'] = $item->tags;
}
}
return $item;
}
And this is my table's constructor:
public function __construct(&$db)
{
parent::__construct('#__bestia_goals', 'id', $db);
JTableObserverTags::createObserver($this, array('typeAlias' => 'com_bestia.goal'));
}
In my table there's also an override for the store-method, because I have to prepare a Calendar-Field with format dd.mm.yyyy to be saved to MySQL DATETIME:
/**
* store function.
*
* @access public
* @param bool $updateNulls (default: false)
* @return void
*/
public function store($updateNulls = false)
{
if(!empty($this->dateofbirth)) // Prepare DOB to be saved in database
{
// Set this to a format the sql-table is able to save
$date = JFactory::getDate($this->dateofbirth);
$this->dateofbirth = $date->toSql();
}
// Use parent store method
$result = parent::store($updateNulls);
return $result;
}
Now my problem is - if I want to save the records, I'm getting this response:
Speichern fehlgeschlagen! Fehler:
Which is translated:
Error by saving! Error:
If I var_dump $result in my store-method, I'm getting back false
. If I remove
JTableObserverTags::createObserver($this, array('typeAlias' => 'com_bestia.goal'));
$result is true
again.
What did I do wrong?