phalcon / phalcon-devtools

Phalcon Developer Tools
https://docs.phalcon.io/latest/en/devtools
Other
1.33k stars 629 forks source link

ncaught TypeError: Argument 1 passed to Phalcon\Flash\AbstractFlash::error() must be of the type string, object given #1516

Closed imakepossible closed 3 years ago

imakepossible commented 3 years ago

I have a form and when i validate it to check email address and when i enter wrong email it gives error message but it is not flashing and giving error "Fatal error: Uncaught TypeError: Argument 1 passed to Phalcon\Flash\AbstractFlash::error() must be of the type string, object given in C:\wamp64\www\phaldemo\app\controllers\UsersController.php on line 152"

Describe what you are trying to achieve and what goes wrong. My code to get errors on submitting form: foreach ($user->getMessages() as $message) {

            $this->flash->error($message);  
        }

$message - when i use print_r($message), i am getting this output Phalcon\Messages\Message Object ( [code:protected] => 0 [field:protected] => email [message:protected] => Please enter a correct email address [type:protected] => Phalcon\Validation\Validator\Email [metaData:protected] => Array ( )

)

But this $this->flash->error($message); giving error "Uncaught TypeError: Argument 1 passed to Phalcon\Flash\AbstractFlash::error() must be of the type string, object given"

How i will able to access protected message value "Please enter a correct email address"