We have two ways of validation of user input data in phalcon.
I trying to merge my model validation with form validation in this way.
$result = $site->save();
if (!$result) {
$messages = $site->getMessages();
/** @var \Phalcon\Mvc\Model\Message $msg */
foreach ($messages as $msg) {
/** @var \Phalcon\Forms\Element $field */
$field = $form->get($msg->getField());
$field->appendMessage(new \Phalcon\Validation\Message($msg->getMessage(), $msg->getField()));
var_dump($form->getMessagesFor($msg->getField()));
var_dump($field->getMessages());
exit;
}
// ....
}
In result i have:
object(Phalcon\Validation\Message\Group)[113]
protected '_position' => null
protected '_messages' => null
object(Phalcon\Validation\Message\Group)[110]
protected '_position' => null
protected '_messages' =>
array (size=1)
0 =>
object(Phalcon\Validation\Message)[111]
protected '_type' => null
protected '_message' => string 'The URL must be unique' (length=22)
protected '_field' => string 'fsurl' (length=5)
Why? What is incorrect in my code or it is a bug?
P.S. Phalcon version is 1.1.0.