Welcome Guest, Not a member yet? Register   Sign In
Pagination/Validation: What to do?
#1

[eluser]carvingCode[/eluser]
Interesting code structure problem I need help with.

I implemented form validation using a if/else block. Checking to see if form was validated -- if not, open form; otherwise, continue on into function.

All worked wonderfully until I added pagination code, which BTW seems to work fine in tests after removing validation if/then statement.

But, with validation code in, clicking on the pagination links bring me back into the function and validation fails and the form opens.

I'm calling the form from a controller function. It sends it's data to the function I'm having problems with. Code is below. Output is sent to a view with a loop.

I've run up against a wall in trying to determine proper program flow and would appreciate any thoughts. If you need additional info, please ask.

TIA

Code:
// In controller
function do_name_search()
{
  $this->form_validation->set_rules('name', 'name','trim|required|min_length[3]|xss_clean');
  if ($this->form_validation->run() == FALSE)
  {
    $this->load->view('search_forms/name_form');
  }
    else
    {
      $search_param = $this->input->post('name');

      $config['base_url']= base_url().'search/do_name_search/';
      $config['per_page']= 10;
      //$config['uri_segment'] = 2;
      $config['total_rows'] = $this->Db_search_model->get_num_rows_like('name',$search_param);
      $this->pagination->initialize($config);

      // query and retrieve data
      $data['query'] = $this->Db_search_model->search_name($search_param,$config['per_page'],$this->uri->segment(2));
      $data['rows'] = $data['query']->num_rows();
      $data['search_param'] = $search_param;
      $data['links']=$this->pagination->create_links();

      $this->load->view('search_results/name_results', $data);
    }
}


Messages In This Thread
Pagination/Validation: What to do? - by El Forum - 04-27-2010, 11:29 AM
Pagination/Validation: What to do? - by El Forum - 04-27-2010, 11:53 AM
Pagination/Validation: What to do? - by El Forum - 04-27-2010, 12:13 PM
Pagination/Validation: What to do? - by El Forum - 04-27-2010, 12:23 PM
Pagination/Validation: What to do? - by El Forum - 04-27-2010, 12:58 PM
Pagination/Validation: What to do? - by El Forum - 04-27-2010, 01:10 PM
Pagination/Validation: What to do? - by El Forum - 04-28-2010, 06:22 AM
Pagination/Validation: What to do? - by El Forum - 04-28-2010, 07:38 AM
Pagination/Validation: What to do? - by El Forum - 04-28-2010, 11:48 AM



Theme © iAndrew 2016 - Forum software by © MyBB