Phalcon 4.0.0 CODE:
1 $usuario = new Usuario(); 2 $usuario->nome = $this->request->getPost("nome"); 3 4 if ( ! $usuario->save() ) { 5 foreach ($usuario->getMessages() as $message) { 6 $this->flash->error($message); 7 } 8 }
Line 6 points as an error that $messege must be a string. Some how it's not a string, but an object, as print_r($message) shows:
Phalcon\Messages\Message Object ( [code:protected] => 0 [field:protected] => nome [message:protected] => nome is required [type:protected] => PresenceOf [metaData:protected] => Array ( ) ) Phalcon\Messages\Message Object ( [code:protected] => 0 [field:protected] => email [message:protected] => email is required [type:protected] => PresenceOf [metaData:protected] => Array ( ) ) Phalcon\Messages\Message Object ( [code:protected] => 0 [field:protected] => senha [message:protected] => senha is required [type:protected] => PresenceOf [metaData:protected] => Array ( ) ) Phalcon\Messages\Message Object ( [code:protected] => 0 [field:protected] => perfil [message:protected] => perfil is required [type:protected] => PresenceOf [metaData:protected] => Array ( ) )
I tried with each: Phalcon\Flash\Direct and also Phalcon\Flash\Session
I can't use $this->flash->error( $message->message ) because it's a protected object, so what should I do?
Thanks