Hello,
I have a problem with saving records on validation process. Problem description:
1) Trying to save() model with some data
2) $client->save() going to $client model and trying to validate data passed from assigning to model (ex. $client->setEmail($form_data['email']);) for uniqueness.
3) Calling function on $client model
public function validation()
{
$this->validate(new \Phalcon\Mvc\Model\Validator\Uniqueness(array(
"field" => "email",
"message" => $this->getDI()->get('translate')->_('Email already exists')
)));
return $this->validationHasFailed() != true;
}
4) When script undertands that e-mail exists then going to translation module and get the translation for message string "Email already exists"
5) On my custom translation adapter there is a code contains $this->createLanguageString($translation); $translation is a string passed from model $client
6) And here is a problem.....
public function createLanguageString($translation)
{
$language_string = new LanguageString();
$language_string->setStringName($translation);
if (!$language_string->save()) {
foreach ($language_string->getMessages() as $message) {
echo $message->getMessage();
}
}
}
$language_string->save() is NOT WORKING properly. $language_string->save() do not return any error. Debugger shows that record is going into the database and database or script returns an INSERT ID, but...... There is NO RECORD IN DATABASE!
Maybe it is because Phalcon do not give to save any other records when previous save() is not finished? Please help. Thank you