Hey, it is not a phalcon bug. It was my mistake to advice you in first place to use setDefault, because that method sets default value in case $entity or $_POST does not have value for the input. My bad sorry :)
My multilanguage setup:
I have a base controller, which my other controllers extend. In this controller i have a method which loads translations from cache file and sets them as a shared resource. Here are fragments from that Controller:
class BaseController extends \Phalcon\DI\Injectable
{
function __construct()
{
// Set language
$this->setLanguage();
}
// Set language
private function setLanguage()
{
// Interface language
$file = 'admin_' . $this->session->cms->settings->interfaceLanguage;
$this->loadLanguageFile('admin', $file);
// public translations based on interface Language
$file = 'jsValidation_' . $this->session->cms->settings->interfaceLanguage;
$this->loadLanguageFile('jsValidation', $file);
}
// Most important method
public function loadLanguageFile($key, $file)
{
$obj = new \Models\Translations();
// This gets the cached file, since i store my translations in Database and i dont want to query them everytime. You can use static phalcon translation files also.
$translations = $obj->getCache($file);
// This section is just for me so i can have multiple "sections" in my translations. E.g.: public, admin, jsValidation e.t.c.
if ($this->di->has('translations')) {
$temp = $this->translations;
} else {
$temp = new \stdClass();
}
$temp->{$key} = $translations;
// This is the most important line, allows you to access trnaslations from everywhere
$this->di->setShared('translations', $temp);
}
}
p.s. If your initial problem was solved you can mark the working answer as a solution, so others can use it :)