![]() |
Form validation & default values - 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: Form validation & default values (/showthread.php?tid=8605) |
Form validation & default values - El Forum - 05-23-2008 [eluser]antiver[/eluser] On the site I'm building, there is a user settings page. During the signup process, the user provides their email address. On the settings page, I need to show the user's current email address setting that's been stored in the database (which I have no idea how to do) so they can just edit it without needing to type the whole thing out. An excerpt from the settings page: Code: Update Email Address I assume I need to either change something in the code above, along with a change in the controller, or just somehow set the value of $this->validation->email in the controller when the page is first loaded. When building all the forms on the site, I followed the guide at http://ellislab.com/codeigniter/user-guide/libraries/validation.html , but don't see anything about setting a default value for a field. I feel like ^ this ^ is kind of vague, so let me know if it needs clarification. Hopefully you're already familiar with the behavior I'm looking for ![]() Thanks! Form validation & default values - El Forum - 05-23-2008 [eluser]Popcorn[/eluser] This has nothing to do with validation. What you will want to do is use a SQL statement to select that information from your users table then simply echo it into position. Form validation & default values - El Forum - 05-23-2008 [eluser]antiver[/eluser] Well yeah, but Code: <input type="text" name="email" value="<?=$this->validation->email?>"> Form validation & default values - El Forum - 05-23-2008 [eluser]antiver[/eluser] I'm currently solving the problem using this code: Code: <? I hope there's a better way... Form validation & default values - El Forum - 05-23-2008 [eluser]Rick Jolly[/eluser] Yup, there's a better way. Simply set the validation field default if the form hasn't been posted yet: Code: if (empty($_POST)) |