Welcome Guest, Not a member yet? Register   Sign In
Edit, validate, re-edit issue using set_value with optional parameter
#16

[eluser]Ben Edmunds[/eluser]
I'm probably missing something because I'm pretty busy right now but try this...

Code:
function edit_creditor($UniqContactID = '')
    {
        /**
         * Edit a creditor given then UniqContactID
         * throws  to an editing screen
         */
        $this->load->helper('form');
        $this->load->model('creditors_model');
        $this->load->helper('form');
        $this->load->library('form_validation');
        
        $data['css'] = $this->css;
        $data['images'] = $this->images;
        $data['jss'] = $this->jss;
        $data['base'] = $this->base;
        $data['robots'] = '<meta name="robots" content="noindex,nofollow">';
        $data['title']="Creditors";  //shows up on tab
        $data['pagetitle']="Screen for Creditors";  //top of page body

        $this->form_validation->set_rules('CategoryID','CategoryID', 'required');
        $this->form_validation->set_rules('Company', 'Company', 'required|min_length[80]');
        $this->form_validation->set_rules('SearchName', 'SearchName', 'required');
        $this->form_validation->set_rules('Building','Building', 'required');
        $this->form_validation->set_rules('StreetNumber','StreetNumber', 'required');
        $this->form_validation->set_rules('Unit','Unit', 'required');
        $this->form_validation->set_rules('StreetNumberSuffix','StreetNumberSuffix', 'required');
        $this->form_validation->set_rules('StreetName','StreetName', 'required');
        $this->form_validation->set_rules('StreetType','StreetType', 'required');
        $this->form_validation->set_rules('StreetDirection','StreetDirection', 'required');
        $this->form_validation->set_rules('Municipality','Municipality', 'required');
        $this->form_validation->set_rules('ProvinceState','ProvinceState', 'required');
        $this->form_validation->set_rules('PostalCodeZip','PostalCodeZip', 'required');
        $this->form_validation->set_rules('Country','Country', 'required');
        $this->form_validation->set_rules('LTCCode','LTCCode', 'required');
        $this->form_validation->set_rules('GovernmentCode','GovernmentCode', 'required');
        $this->form_validation->set_rules('PrivacyPolicyExempt','PrivacyPolicyExempt', 'required');
        $this->form_validation->set_rules('ProofOfClaimRequired','ProofOfClaimRequired', 'required');
        $this->form_validation->set_rules('AdditionalInformation','AdditionalInformation', 'required');
        
        $this->form_validation->run(); //will fail on run thru because no post data

        //We haven't got any data yet .. ie) first time in record.
        $creditors = $this->creditors_model->get_creditor($UniqContactID)->row_array();

        $data = array_merge($data, $creditors);

        if(empty($_POST['BtnSaveCredType']))
        {
            $data['BtnSaveCredType'] = 'Save Changes';
            // now go in and bring up the form.
            $this->load->view('header_view',$data);
            $this->load->view('menu_view');
            $this->load->view('creditor_edit_view', $data);  
            $this->load->view('footer_view',$data);    
        }
        else
        {
            //We're into re-editing
            $data['BtnSaveCredType'] = 'Save Revised Changes';
            if ($this->form_validation->run() == FALSE)
            {
            
                $this->load->view('header_view',$data);
                $this->load->view('menu_view');
                $this->load->view('creditor_edit_view', $data);  
                $this->load->view('footer_view',$data);
                
            }
            else
            {
                // call model to save data  here.
                
            }
            
        };
    
    }


Messages In This Thread
Edit, validate, re-edit issue using set_value with optional parameter - by El Forum - 03-19-2010, 12:07 PM



Theme © iAndrew 2016 - Forum software by © MyBB