Explanation about errors, please? - Printable Version +- CodeIgniter Forums (https://forum.codeigniter.com) +-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20) +--- Forum: Archived Development & Programming (https://forum.codeigniter.com/forumdisplay.php?fid=23) +--- Thread: Explanation about errors, please? (/showthread.php?tid=34495) |
Explanation about errors, please? - El Forum - 10-01-2010 [eluser]victorche[/eluser] Tried to find an answer in the user guide and forums ... No success! My problem is with the errors/messages which are displayed after a form submission. And in all the examples / tutorials I can find only one solution. There is always a div, for example: Code: <div id="message"><?php echo $message; ?></div> So far, so good. But I want to style this div with CSS, adding some beauty in it And the problem is... It is hardcoded in the template (the view file I mean). So if there is no style, then yes. The div is not visible, until it is populated with some text from the message. But when I add some style, then it is always visible. Maybe my explanation was not good enough. But I am looking for a way, not only to display the error/message as a text. I need a whole div, which is showing after there is a post (form submit). This div to appear then, with the design and styles. And then maybe I will hide it with some jQuery stuff Any ideas, or links to such kind of approach? I mean examples, or tutorials ... Thanks in advance! Explanation about errors, please? - El Forum - 10-01-2010 [eluser]Ki[/eluser] I assume you are trying to display messages/errors to the user only when such are set. I have approached it in my application in the following way. In my helper functions, I have created a function set_msg() that adds any messages to $this->data['messages'] multidimensional array. In my views or controllers (or models) all I have to do is set_msg('Example of text to display','message type'). For example, when I call set_msg('Invalid Login','error') I will get this->data['messages']['errors'][0] => 'Invalid Login'. Then, in my header, where I want to display the messages: Code: if(!empty($messages)){ This will allow you to have each type of message group in their own div with separate CSS styling. Explanation about errors, please? - El Forum - 10-01-2010 [eluser]victorche[/eluser] Thanks, @Ki! I am looking for something like this, correct. I don't want this div to stay always in my header. I need it only after submitting a form. Then the div can display error or info message. Can you give me some hint about the helper, connected with this? |