Passing form validation errors to an include file - 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: Passing form validation errors to an include file (/showthread.php?tid=19074) |
Passing form validation errors to an include file - El Forum - 05-27-2009 [eluser]opel[/eluser] I have a newsletter sign up for that I want to include on my site on different pages. I have created a method "newsletter" in my contact controller like so : Code: function newsletter() If a form is successful it redirects back to the page the form was posted from. The problem I am having is to get the validation error messages to post back to the form. I have included the validation errors function at the top of my include file so that it appears with the form. Any ideas on how I can get the validation errors to post back please ? Passing form validation errors to an include file - El Forum - 05-27-2009 [eluser]Dam1an[/eluser] The reason you're not getting the errors displayed is cause you're redirecting, which ends this request and throws away the error data Normally, you'd just load a view and display the errors there So you'll either need to store the errors in a session var and manually display them, or load the view instead of a redirect Passing form validation errors to an include file - El Forum - 05-27-2009 [eluser]opel[/eluser] Ok I'll try that cheers Passing form validation errors to an include file - El Forum - 05-27-2009 [eluser]opel[/eluser] I couldn't get it working ended up putting it in the controller. I have a Base_Controller that all my other front end controllers extend from. I tried putting the above function in there but the form was loading in the wrong place. I even tried assigning it to a variable with no luck. Any suggestions how you have or would get round the problem ? Cheers Passing form validation errors to an include file - El Forum - 05-27-2009 [eluser]TheFuzzy0ne[/eluser] Please show your code as it is now. Usually, your controller method will do something like this: Code: $this->load->library('form_validation'); Hope this helps. Passing form validation errors to an include file - El Forum - 05-27-2009 [eluser]opel[/eluser] I am using the "simple template library". So the above works I just couldn't get it in the correct place. I will try again later but deadline approaches |