Welcome Guest, Not a member yet? Register   Sign In
views displaying twice after upgrading to new release
#11

[eluser]TheFuzzy0ne[/eluser]
I'm assuming it's just where he's stripped out some of the data such as sensitive information and JavaScript. If that was his production code, it would most certainly throw a fatal parsing error.
#12

[eluser]sentinel[/eluser]
Hi,

It did a cut and paste, and it must have pasted it in a weird way.

I just checked, and the URLs seem correct. As mentioned above, they wouldn't parse anyway.

I will get the latest release, and start again from scratch.

Neil.
#13

[eluser]sentinel[/eluser]
Hi,

Sorry to come back to this, but I'm no further forwards.

I did a fresh install, and went through everything carefully.

The strange thing is when I bult a simple stripped down test controller, it worked like it is meant to do. This is what I used:

Code:
<?php
class Temp extends Controller {

        function Temp()
        {
                parent::Controller();
                }


        function index(){


        
        $data['title'] = 'Investment Bond Toolkit';
        $data['header'] = 'Manage Saved Bonds';
        $data['content'] = $this->load->view('temp',$input, TRUE);


        $this->load->vars($data);      
        $this->load->view('maintemplate');

        }
                        }
?>

And for the view:

Code:
<table class="maintable">
   <tr>
    <td width="5%">&nbsp;</td>
    <td width="35%">&nbsp;</td>
    <td width="30%">&nbsp;</td>
    <td width="10%">&nbsp;</td>
    <td width="10%">&nbsp;</td>
    <td width="10%">&nbsp;</td>
  </tr>
  <tr>
    <td>&nbsp;</td>
    <td>&nbsp;</td>
    <td>&nbsp;</td>
    <td>&nbsp;</td>
    <td>&nbsp;</td>
    <td>&nbsp;</td>
  </tr>
  <tr>
    <td>&nbsp;</td>
    <td>&nbsp;</td>
    <td>&nbsp;</td>
    <td>&nbsp;</td>
    <td>&nbsp;</td>
    <td>&nbsp;</td>
  </tr>
</table>

Now, if I compare it to another controller, there is no fundamental difference in the way it renders the views:

Code:
&lt;?php
class Policyholders extends Controller {

    function Policyholders()
    {
        parent::Controller();
         $this->load->model('policyholders_model','',TRUE);
        }


    function index(){

    //
        // Check if User ID has been set
        
               $input['policyholders'] = $this->policyholders_model->load_policyholders();
                


// Create array with FORM elements to pass to view

        $input['page'] ='policyholders';
    $form_attributes = array('id' => $input['page'], 'name' => $input['page']);
    $input['open'] = form_open('policyholders', $form_attributes);
        $input['close'] = form_close();
        $input['firstName'] = form_hidden('firstName', '');
        $input['surname'] = form_hidden('surname', '');
        $input['policyholderId'] = form_hidden('policyholderId', '');
        $input['process'] = form_hidden('process', '');
    


        $form_attributes = array('id' => $input['page'], 'name' => $input['page']);


        $rules['process'] = "required";
                $rules['firstName'] = "trim|required";
                $rules['surname'] = "trim|required";
                $rules['policyholderId'] = "trim|required";

    $this->validation->set_error_delimiters('<div class="error">ERROR! ', '</div>');
    $this->validation->set_rules($rules);

                $fields['process'] = "";
                $fields['firstName'] = "";
                $fields['surname'] = "";
                $fields['policyholderId'] = "";

    $this->validation->set_fields($fields);

                if ($this->validation->run() == FALSE)
                {
                $this->load->view('policyholder');
                }
                else
                {

        if($this->input->post('process') == "redirect") {
            
          $newdata = array('policyholderId'=> $this->input->post('policyholderId'));
                  $this->db_session->set_userdata($newdata);


                        $newdata = array('ammend'=> '1');
                        $this->db_session->set_userdata($newdata);

                        header('location: '.site_url().'policyholder');exit;
            }
        if($this->input->post('process') == "delete") {

            $this->policyholders_model->delete_policyholder();

                        header('location: '.site_url().'policyholders');exit;

                }

                           }  


    $data['title'] = 'Investment Bond Toolkit';
    $data['header'] = 'Edit or Delete Policyholders / Beneficiaries';
    $data['content'] = $this->load->view('policyholders',$input, TRUE);


    $this->load->vars($data);    
    $this->load->view('maintemplate');

    }
}
?&gt;


I just can't see where the problem lies.

I would guess it has to lie in the controllers or views (I doubt the models have any bearing on it). And I've been over the config files so many times that I can't see anything out of place there.

Any other suggestions would be appreciated, otherwise I'll just have to abandon the upgrade and stick with the existing version.

Many Thanks.

Neil.
#14

[eluser]xwero[/eluser]
i think this is the problem
Code:
if ($this->validation->run() == FALSE)
                {
                $this->load->view('policyholder');
                }
#15

[eluser]sentinel[/eluser]
Well done sir. That was indeed the problem. I changed it to:

Code:
if ($this->validation->run() == TRUE)
                {

                if($this->input->post('process') == "redirect") {

                  $newdata = array('policyholderId'=> $this->input->post('policyholderId'));
                  $this->db_session->set_userdata($newdata);


                        $newdata = array('ammend'=> '1');
                        $this->db_session->set_userdata($newdata);

                        header('location: '.site_url().'policyholder');exit;
                        }
                if($this->input->post('process') == "delete") {

                        $this->policyholders_model->delete_policyholder();

                         header('location: '.site_url().'policyholders');exit;

                                }

                           }

Now it works like the old version.

I made the (wrong) assumption that because it worked last time, it would continue working. I assume some changes in the underlying CI libraries caused it to behave differently.

Anyway, all sorted.

Many thanks for all your help.

Regards.
Neil.
#16

[eluser]TheFuzzy0ne[/eluser]
I've taken the liberty of modifying your code slightly so that the validation runs and the rules are only loaded if the form is being submitted.
Code:
&lt;?php
    function index()
    {
        if ($this->input->post('policyholderId')) // Is the form being submitted?
        {
            $rules['process'] = "required";
            $rules['firstName'] = "trim|required";
            $rules['surname'] = "trim|required";
            $rules['policyholderId'] = "trim|required";
    
            $this->validation->set_error_delimiters('<div class="error">ERROR! ', '</div>');
            $this->validation->set_rules($rules);
            
            $fields['process'] = "";
            $fields['firstName'] = "";
            $fields['surname'] = "";
            $fields['policyholderId'] = "";
    
            $this->validation->set_fields($fields);
            
            if ($this->validation->run() == TRUE)
            {
            
                if($this->input->post('process') == "redirect")
                {
                    $newdata = array('policyholderId'=> $this->input->post('policyholderId'));
                    $this->db_session->set_userdata($newdata);
                    
                    
                    $newdata = array('ammend'=> '1');
                    $this->db_session->set_userdata($newdata);
                    
                    header('location: '.site_url().'policyholder');exit;
                }
                
                if($this->input->post('process') == "delete")
                {
                    $this->policyholders_model->delete_policyholder();
                    
                    header('location: '.site_url().'policyholders');exit;
                }
            }
            else
            {
                # Not sure what this is for, but I agree with xwero that it's causing your problem.
                // $this->load->view('policyholder');
            }
        }
        
        // Check if User ID has been set
        
        $input['policyholders'] = $this->policyholders_model->load_policyholders();
                
        // Create array with FORM elements to pass to view
        
        $input['page'] ='policyholders';
        $form_attributes = array('id' => $input['page'], 'name' => $input['page']);
        $input['open'] = form_open('policyholders', $form_attributes);
        $input['close'] = form_close();
        $input['firstName'] = form_hidden('firstName', '');
        $input['surname'] = form_hidden('surname', '');
        $input['policyholderId'] = form_hidden('policyholderId', '');
        $input['process'] = form_hidden('process', '');
        
        $form_attributes = array('id' => $input['page'], 'name' => $input['page']);
        
        $data['title'] = 'Investment Bond Toolkit';
        $data['header'] = 'Edit or Delete Policyholders / Beneficiaries';
        $data['content'] = $this->load->view('policyholders',$input, TRUE);
        
        $this->load->vars($data);  
        $this->load->view('maintemplate');
    }

EDIT: DOH! Too slow... glad you got it sorted. It just goes to show how much quicker problems can be solved when you share your code, and have experts to hand such as xwero.
#17

[eluser]sentinel[/eluser]
Many thanks for taking the time to ammend this.

It does make more sense to do it this way.

I can now crack on and finish off the project.

Neil.




Theme © iAndrew 2016 - Forum software by © MyBB