What is the best way to generate and display user defined errors?

7 views
Skip to first unread message

murat erkenov

unread,
May 12, 2011, 8:24:03 AM5/12/11
to Zend Framework Developers
Hi everybody. I'm just starting to learn ZF.
I would like to know if there is a good way to generate and then
display messages which happen when users do something wrong (or may be
something correct).
For example: if user tries to login and fails system should display
something like "Incorrect Login/Password".
Another example: when user tries to register and succeed, I want to
output "Congratulation. You've successfully signed up".

What is the best practice for such cases? I tried to search among ZF
docs and did not find.
For example in Joomla's framework I used such way to generate
messages:

JError::raiseWarning('Incorrect Login/Password');
it added messages to special queue and then I was able to get messages
from that queue in any place of my script.
It is very convenient when I want to output messages in some
particluar place of template.

Randell

unread,
May 12, 2011, 11:25:14 AM5/12/11
to zfdeve...@googlegroups.com
You can checkout Zend Form (http://framework.zend.com/manual/en/zend.form.forms.html), which comes with it's own validation mechanism wherein you can specify the error messages.

You can also checkout the FlashMessenger (http://framework.zend.com/manual/en/zend.controller.actionhelpers.html) helper to show the success messages.

Depending on the requirements of your projects, you can also simply pass the message in $this->view->variablenameofyourchoice from the controller and access it from the view using $this->variablenameofyourchoice .


--
Randell


--
You received this message because you are subscribed to the Google Groups "Zend Framework Developers" group.
To post to this group, send email to zfdeve...@googlegroups.com.
To unsubscribe from this group, send email to zfdevelopers...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/zfdevelopers?hl=en.


void

unread,
May 12, 2011, 11:30:32 AM5/12/11
to Zend Framework Developers
I think the best way of displaying messages is using the
flashMessenger helper to memorize all your messages and display them
when and where you want. You can find more info on the official
documentation:

http://framework.zend.com/manual/en/zend.controller.actionhelpers.html#zend.controller.actionhelper.initialization
Reply all
Reply to author
Forward
0 new messages