Welcome Guest, Not a member yet? Register   Sign In
update from best practice
#5

[eluser]PhilTem[/eluser]
I think I now got your point (hopefully). Try to run the form-validation within the same if-branch as you do the check for post-values like so

Code:
function edit()
{
    // if form submitted and validated
    if( $this->input->post('submit') && ( $this->form_validation->run() == TRUE ) )
    {
        // save data
        $this->model->saveFromPost($this->input);
        // redirect to success page
        redirect('/controller/editsuccess');
    }
    else
    {
        // read data from db and show to user
        $data = $this->model->getData();
        // variable 'data' defined in view
        $this->load->view('controller/edit', array('data'=>$data));
    }
}

This way you will always have variable $data within your edit-view no matter if the form was submitted or not. If this didn't solve your question maybe I'll have to read your posts more precisely Tongue


Messages In This Thread
update from best practice - by El Forum - 03-04-2012, 09:49 AM
update from best practice - by El Forum - 03-04-2012, 11:54 AM
update from best practice - by El Forum - 03-04-2012, 09:05 PM
update from best practice - by El Forum - 03-06-2012, 02:04 AM
update from best practice - by El Forum - 03-08-2012, 02:29 AM
update from best practice - by El Forum - 03-08-2012, 06:37 AM
update from best practice - by El Forum - 03-08-2012, 08:23 AM



Theme © iAndrew 2016 - Forum software by © MyBB