Welcome Guest, Not a member yet? Register   Sign In
validation : return formatted rule fields
#1

[eluser]xwero[/eluser]
I don't know if it's possible so i want to ask it first.

The idea behind it is simple. You have all those rules to validate the input and when the validation succeeds you can use the rules instead of doing the same thing over again with the post variables.

In code this would be something like this

Code:
$this->load->library('validation');
        
$rules['username'] = "trim|required|min_length[5]|max_length[12]|xss_clean";
$rules['password'] = "trim|required|matches[passconf]|md5";
$rules['passconf'] = "trim|required";
$rules['email'] = "trim|required|valid_email";
    
$this->validation->set_rules($rules);
    
$fields['username']    = 'Username';
$fields['password']    = 'Password';
$fields['passconf']    = 'Password Confirmation';
$fields['email']    = 'Email Address';

$this->validation->set_fields($fields);
        
if ($this->validation->run() == FALSE)
{
    $this->load->view('myform');
}
else
{
    $this->model->add($this->validation->username,$this->validation->password,$this->validation->passconf,$this->validation->email);
    $this->load->view('formsuccess');
}

I tested this example but the $this->validation->username returned the post variable.


Messages In This Thread
validation : return formatted rule fields - by El Forum - 08-23-2007, 02:28 AM
validation : return formatted rule fields - by El Forum - 08-23-2007, 01:52 PM
validation : return formatted rule fields - by El Forum - 08-23-2007, 07:47 PM



Theme © iAndrew 2016 - Forum software by © MyBB