We have moved our forum to GitHub Discussions. For questions about Phalcon v3/v4/v5 you can visit here and for Phalcon v6 here.

Error on validation related model

I am trying to save a model and a related one. But when I execute save() on parent, it fires a error from related model validation.

Related model validation:

    public function validation()
    {
      if(!$this->getName())
      {
        $this->appendMessage(new \Phalcon\Mvc\Model\Message('Invalid Name'));
      }

Error:

Invalid message format 'string'

Why it's not appending the right message? If I remove validation both are saved properly.

Validation can produce multiple error messages. Are you just outputing 1? If you just output the first or last message - you may be missing some messages.

Do you have a return value in the validation() function?

Add return false inside the if statement and return true outside it.

Tried. Didnt work. =/

Do you have a return value in the validation() function?

Add return false inside the if statement and return true outside it.