Welcome Guest, Not a member yet? Register   Sign In
Validation form with fields filled
#1

[eluser]indapublic[/eluser]
There is form with update user profile.

Code:
<div>Username: &lt;?=$this->validation->username_error;?&gt;&lt;input type="text" name="username" value="&lt;?=$this-&gt;validation->username;?&gt;" /></div>

How can I fill fields before the form show?

Code
Code:
$user = $this->user_model->get_user_data($user_id);
$this->validation->username = $user->username;
$rules["username"] = "trim|required|xss_clean";
$this->validation->set_rules($rules);
$fields["username"] = "username";
$this->validation->set_fields($fields);
$this->load->view("users/edit", $user);
is not working.
#2

[eluser]mdvaldosta[/eluser]
Validation will only have values once the form is submitted. You'd need to send the pre-populated form variables to the view from your controller first. Then, do an if statement to use the validation values if they exist, else use the database values. Or, something like that.
#3

[eluser]indapublic[/eluser]
Ok, i understand. Thanks a lot




Theme © iAndrew 2016 - Forum software by © MyBB