• 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
How to set segment to view in codeigniter after form validation fails?

#1
[eluser]Unknown[/eluser]
I am validating a form on many views that are generated by the third URL segment.

The URL: http://example.com/listings/item/12 (The 12 will change based on item)

Both my functions are below, my question is, when the validation fails how to I refresh the page with the 3rd segment and show the validation errors?

P.S: I have already tried redirect() but the validation errors don't remain.

Thank You.

This is the "item" function

Code:
public function item()
{

    if ($this->session->userdata('is_logged_in'))
    {
        $id = $this->uri->segment(3);
        $this->load->model('listings_model');

        if ($data['things']= $this->listings_model->get_item($id))
        {
            $this->load->view('list/item_view',$data);
        }
    }
    else
    {
         $this->unauth();
    }
}


This is my validation.
Code:
public function get_email()
{

    $this->load->library('form_validation');


        $this->form_validation->set_rules('captcha', 'Captcha', 'required|trim|callback_check_captcha' );


        if ($this->form_validation->run() == FALSE)
        {
           $this->item();
        }
        else
        {
            $this->load->model('listings_model');

            if ($this->listings_model->update_listing())
            {
                echo "Good";
            }

        }
}


Messages In This Thread
How to set segment to view in codeigniter after form validation fails? - by El Forum - 03-22-2013, 08:42 PM

Digg   Delicious   Reddit   Facebook   Twitter   StumbleUpon  


Users browsing this thread:
1 Guest(s)


  Theme © 2014 iAndrew  
Powered By MyBB, © 2002-2019 MyBB Group.