[eluser]awells527[/eluser]
Hi all, I'm attempting to process multiple forms in the same request. Basically, sections of the form may succeed while other parts may fail. I'm doing it like this:
Code:
/* changing the email address */
if ($this->input->post('email_confirm') != '')
{
$this->form_validation->set_rules('email', 'Email', 'trim|required|max_length[128]');
$this->form_validation->set_rules('email_confirm', 'Email Confirm', 'trim|required|max_length[128]|matches[email]');
if ($this->form_validation->run() != FALSE)
{
/* process code */
}
else
{
/* show error message, etc */
}
}
/* changing the password */
if ($this->input->post('password') != '' || $this->input->post('password_confirm') != '')
{
$this->form_validation->set_rules('password', 'Password', 'trim|required|max_length[128]|sha1');
$this->form_validation->set_rules('password_confirm', 'Password Confirm', 'trim|required|max_length[128]|matches[password]');
if ($this->form_validation->run() != FALSE)
{
/* process code */
}
else
{
/* show error message, etc */
}
}
So there are two different sections where form data is processed. On the form, there are places to enter an email address and a new password. They may fill out both, one, or neither. The problem is that if they mess up the email but validate a new password, the second $this->form_validation->run() fails because it still has the email rules loaded.
So the question is, can I clear out the rules in the same request to form a new validation?