Scenario:
Object JSON, correctly saved in the DB, thanks to the function "SAVE" in the item model (part of the function involved).
everything is fine here:
if (isset($data['extra_options']) && is_array($data['extra_options']))
{
$registry = new JRegistry;
$registry->loadArray($data['extra_options']);
$data['extra_options'] = (string) $registry;
}
it is also correctly retrieved in the "populateObjects" function in the same item model through the (part of the funciton involved):
if (!empty($item->extra_options))
{
$registry = new JRegistry;
$registry->loadString($item->extra_options);
$item->extra_options = new JObject($registry->toObject());
}
BUT for some unknown reason, the item is overridden somewhere in the model/view and the Object Json field is become empty.
my dirty workaround is making an empty populateObjects function in the model item fork:
public function populateObjects(&$item)
{
}
and using the simple json_decode in the view function of the fork view:
protected function displayGroup($tpl = null){
parent::displayGroup($tpl);
$this->item->extra_options = json_decode($this->item->extra_options);
}