Welcome Guest, Not a member yet? Register   Sign In
Using a different controller to perform validation than the one creating the form
#3

[eluser]gnomishperson[/eluser]
I believe I solved my problem by putting the validation into the show() function and using findings() as a process function only, and using the form to submit to /show/$case_id.

Change to the end of show():
Code:
show()
{
            /*********************
            ** Added Validation **
            *********************/

            $rules['pathologic_description']  = "trim|required|xss_clean";
            $rules['microscopic_description'] = "trim|xss_clean";
            
            $this->validation->set_message('required', 'You are missing one or more required fields');        

            $this->validation->set_rules($rules);

            if ($this->validation->run() == FALSE)
            {
                $this->load->vars($data);

                $this->load->view($this->_container);
            }
            else
            {
                $this->findings();
            }
Change to findings():
Code:
function findings()
    {
      
        /***********************
        ** Removed Validation **
        ***********************/
            if (!$submit)
            {
                echo 'Attempting to Save';
                //$this->saveCase($id, $final, $micro);
            }
            else
            {
                echo 'Trying to submit';
                //$this->submitCase($id, $final, $micro);
            }
    }
Change to detail view:
Code:
<?=form_open('pathologist/'.$controller.'/show/'.$pathologist['case_id'])?>

I feel kinda silly about all this now, after the fix seemed so simple and obvious.


Messages In This Thread
Using a different controller to perform validation than the one creating the form - by El Forum - 07-15-2008, 08:09 AM



Theme © iAndrew 2016 - Forum software by © MyBB