[eluser]frist44[/eluser]
I'm trying to use DMZ in my new application and I've hit a little speed bump. I worked out a registration page and everything was good because I would do a $obj->save() and validation would run. If something was wrong, I pass the obj to the view and the error message shows next to the field.
However, now I'm doing a save(), because this is for a "forgot password" page. So I want the user to input an email address. From that email, I look up a user account, and if valid, send that email their credentials. However, when I submit the form without an address, it doesn't go through validation. I looked at the $obj->validate() method, and I have a feeling that's what I'm supposed to go to, but can't figure it out. This is what I have so far.
Code:
public function index() {
if (is_logged_in()) redirect(base_url());
$u = new User();
$data['obj'] = $u;
$data['content_view'] = 'forgot_view';
if (!is_submitted()) {
$this->load->view('container_view', $data);
} else {
$u = new User();
$u->email = $this->input->post('email');
if ($u->validate()->get()) {
if ($u->exists()) {
// send forgot password email
redirect_with_success(base_url(), 'flash_success_forgot');
} else {
redirect_with_error(base_url() . 'forgot', 'flash_error_forgot');
}
} else {
$this->load->view('container_view', $data);
}
}
}