Easier way to populate form data and validation data? |
[eluser]Unknown[/eluser]
I'm new to code igniter. I'm following the form validation tutorial found at: http://www.codeignitor.com/user_guide/li...ation.html I find I am typing too much in the view to get the form to re-populate. For example, here's what one of my INPUT fields look like: Code: <input type="text" name="email" value="<?=$this->validation->email ? $this->validation->email : $array_db_values['email'] ?>" /> Basically, when the form first loads, it should show a value from the database. If the user alters the value and it fails validation, then the form should post the erroneously submitted value. Does code igniter have a "cleaner" way of rendering this kind of output? Otherwise, I'm going to do something like this in my controller: Code: $array_db_values = getdbresults(); That way, if postback data exists, it will always override database values. Then input fields in my view can simply be: Code: <input type="text" name="email" value="<?=$array_db_values['email'] ?>" /> Is there a better/native CI way to handle this scenario?
[eluser]zbrox[/eluser]
I think you're looking for set_value. You can read more in the user guide http://ellislab.com/codeigniter/user-gui...latingform |
Welcome Guest, Not a member yet? Register Sign In |