Form validation & default values |
[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-gui...ation.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!
[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.
[eluser]antiver[/eluser]
Well yeah, but Code: <input type="text" name="email" value="<?=$this->validation->email?>">
[eluser]antiver[/eluser]
I'm currently solving the problem using this code: Code: <? I hope there's a better way...
[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)) |
Welcome Guest, Not a member yet? Register Sign In |