![]() |
Display notices to the user - Printable Version +- CodeIgniter Forums (https://forum.codeigniter.com) +-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20) +--- Forum: Archived General Discussion (https://forum.codeigniter.com/forumdisplay.php?fid=21) +--- Thread: Display notices to the user (/showthread.php?tid=26471) |
Display notices to the user - El Forum - 01-14-2010 [eluser]Jmz[/eluser] I've got a feeling I'm missing something really obvious here but I'll ask anyway. I've made a controller that lets people edit staff members in the system. Code: function edit_process(){ If it all goes through successfully the user is redirected to admin/staff. How can I tell this page to display some sort of notification to say the user was updated? Display notices to the user - El Forum - 01-14-2010 [eluser]danmontgomery[/eluser] http://ellislab.com/codeigniter/user-guide/libraries/sessions.html Look for the section titled "Flashdata". Display notices to the user - El Forum - 01-14-2010 [eluser]Jmz[/eluser] Ah, I only read that the other day. I knew it was a stupid question! Display notices to the user - El Forum - 01-15-2010 [eluser]Jmz[/eluser] I have another question on the code above so I thought I'd ask here rather than create a new thread. My URL for editing a user looks like mysite.com/admin/staff/edit/1 where the 1 is the ID of the user. If the form validation fails I want to show the form again with the validation error but I can't load the edit view again because I need the ID in the URL and if I redirect it doesn't show the error, would I use flashdata for this aswell or is there a better way? Display notices to the user - El Forum - 01-15-2010 [eluser]flaky[/eluser] you could do this Code: //in the view Display notices to the user - El Forum - 01-15-2010 [eluser]danmontgomery[/eluser] Or just have your form submit to the current page, and perform all of the editing on that page so that when validation fails you're still on /admin/staff/edit/1 Display notices to the user - El Forum - 01-15-2010 [eluser]Jmz[/eluser] flaky. I'm not sure what you mean :red: noctrum, do you mean do an if to see if any form info has been sent in the controller, if it has process the form, if it hasn't show the form? Display notices to the user - El Forum - 01-15-2010 [eluser]flaky[/eluser] Hope this makes it clear what I'm trying to say, by using one single method I can do 2 things, insert and update. Example Code: <?php Display notices to the user - El Forum - 01-15-2010 [eluser]danmontgomery[/eluser] [quote author="Jmz" date="1263590711"]flaky. I'm not sure what you mean :red: noctrum, do you mean do an if to see if any form info has been sent in the controller, if it has process the form, if it hasn't show the form?[/quote] Code: if($this->form_validation->run()) Display notices to the user - El Forum - 01-16-2010 [eluser]flaky[/eluser] Code: $this->load->library('form_validation'); |