Welcome Guest, Not a member yet? Register   Sign In
Pagination throws form validation error when clicking links
#1

[eluser]zulubanslee[/eluser]
Using pagination library. Everything is working except when I click on one of the page links, it gets intercepted by the form validation library. Problem is it doesn't print anything, no errors nothing. Here is my controller:

Code:
function search_by_zip_result()
  {
    
    $this->load->library('zipcode_class');
    $vehicle_type     = $this->input->post('vehicle_type_search');
    $vehicle_subtype  = $this->input->post('vehicle_subtype_search');
    $vehicle_make     = $this->input->post('vehicle_make_search');
    $vehicle_model    = $this->input->post('vehicle_model_search');
    $from_price       = $this->input->post('from_price');
    $to_price         = $this->input->post('to_price');
    $from_year        = $this->input->post('from_year');
    $to_year          = $this->input->post('to_year');
    $radius           = $this->input->post('radius');
    $zip              = $this->input->post('search_by_zip');


    $this->form_validation->set_rules('search_by_zip', 'Zip Code', 'trim|required|min_length[5]|max_length[5]|integer|xss');
    $this->form_validation->set_rules('from_price', 'Price From', 'trim|integer|xss');
    $this->form_validation->set_rules('to_price', 'Price to', 'trim|integer|xss');
    if($this->form_validation->run() == FALSE)
    {
      echo 'error';
      echo validation_errors();
      exit();
    }

    $lat          = '';
    $lon          = '';
    $city         = '';
    $state        = '';
    $state_prefix = '';

    $lat_lon_rc = $this->_get_lat_long_zip($zip);
    if($lat_lon_rc)
    {
      foreach($lat_lon_rc->result() as $lat_lon_row )
       {
         $lat           = $lat_lon_row->lat;
         $lon           = $lat_lon_row->lon;
         $city          = $lat_lon_row->city;
         $state         = $lat_lon_row->state_name;
         $state_prefix  = $lat_lon_row->state_prefix;
       }
    }
  

   $zips_in_radius = $this->zipcode_class->zipcodeRadius($lat, $lon, $radius);
   if($zips_in_radius)
   {  
     // Now get all the vehicles subimtted within those zip codes.    
    
  
    // Get the count of records for pagination
     $vehicle_result_count = $this->_get_vehicles_in_radius_zip($zips_in_radius,
                                                          $vehicle_type,
                                                          $vehicle_make,
                                                          $vehicle_subtype,
                                                          $vehicle_model,
                                                          $from_year,
                                                          $to_year,
                                                          $from_price,
                                                          $to_price,
                                                          $limit = null ,
                                                          $offset  = null);

    
     if($vehicle_result_count)
     {      
       $config['base_url'] = base_url().'search/search_by_zip_result/';
       $config['total_rows'] = count($vehicle_result_count->result());
       $config['per_page'] = 3;
      
       $limit = $config['per_page'];
       $config['uri_segment'] = 4;
       $offset = $config['uri_segment'];
      
       $vehicle_result_2 = $this->_get_vehicles_in_radius_zip($zips_in_radius,  $vehicle_type, $vehicle_make, $vehicle_subtype, $vehicle_model,
                                                              $from_year, $to_year, $from_price,$to_price,
                                                              $limit, $offset);
    
       $this->pagination->initialize($config);
      
       $subview['page_links'] = $this->pagination->create_links();
      
       $data['menu']              = $this->mylib->get_menu();
       $data['sidebar_content']   = $this->mylib->_load_sidebars();
       $data['page_header']       = 'Click on the ad to see details';
       $subview['search_results'] = $vehicle_result_2;
       $data['search_results']    = $this->load->view('search/results', $subview, TRUE);
       $this->load->view('welcome_message', $data);
     }
     else
     {
       redirect(base_url().'search/search_by_zip_result',
               $this->session->set_flashdata('results_not_found', 'No results for those search criteria.' ));
     }

   }
   else
   {
     echo 'no zips codes ';
     exit();
   }  
}


Messages In This Thread
Pagination throws form validation error when clicking links - by El Forum - 08-03-2012, 04:12 PM



Theme © iAndrew 2016 - Forum software by © MyBB