CodeIgniter Forums
Trigger update message from method? - 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: Trigger update message from method? (/showthread.php?tid=26669)



Trigger update message from method? - El Forum - 01-20-2010

[eluser]rich.a.coy[/eluser]
I'm new to MVC. What's the best way to trigger a "Your Information Has Been updated" type message from a controller back to a view? I'm redirecting back to the same page so I can't just hard code a message onto the page.

Thanks.


Trigger update message from method? - El Forum - 01-20-2010

[eluser]Twisted1919[/eluser]
use sessions to store the message , then in the view check the session then flush it .


Trigger update message from method? - El Forum - 01-20-2010

[eluser]rich.a.coy[/eluser]
Thanks for your quick reply.

So use something like set_userdata($message) in the controller and unset_userdata($message) in the view after the message is displayed?


Trigger update message from method? - El Forum - 01-20-2010

[eluser]Twisted1919[/eluser]
I would go with session flashdata : http://ellislab.com/codeigniter/user-guide/libraries/sessions.html [ see Flashdata section ]
CodeIgniter supports "flashdata", or session data that will only be available for the next server request, and are then automatically cleared. These can be very useful, and are typically used for informational or status messages (for example: "record 2 deleted").


Trigger update message from method? - El Forum - 01-20-2010

[eluser]rich.a.coy[/eluser]
Awesome. Thanks for the help!