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

User feedback of errors

Does Phalcon have a means to communicate errors to users? For example, I'm currently building a form. I want to show the user an error if the "Name" field isn't provided.

Traditionally in my apps, I've used a static Error class. Throughout my application if an error was generated it would get stored in the Error class. Then, right before the output gets generated, I check if that static class has any errors recorded. If so, I pass them to the template to be displayed, and the template displays them.

Does Phalcon have any functionaltiy that serves a similar purpose?

You can also use the flash messenger. When an error happens you just store it in there and errors will be displayed to the user.

https://docs.phalcon.io/en/latest/reference/flash.html

@boston - thanks. I think that's just what I need. @Nik - I don't like the flash messenger because it generates markup. I want to be able to output the text of the error myself in the template.

Up to you of course - you know the requirements of your project. :)

You can always change the classes that the markup generated (from the flash) that might suit your needs. Just a thought.



98.9k

@quasipickle Check how the messages are presented in Vokuro:

https://vokuro.phalcon.io/session/signup

Press the button "Sign Up" without entering any field.

https://github.com/phalcon/vokuro