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

[eluser]billmce[/eluser]
Still sucking mud .. :-(

Revised controller (changed view's to 'creditor_edit_view') the rest is as per your change.
==================
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

        
        if(empty($_POST['BtnSaveCredType']))
        {
            //We haven't got any data yet .. ie) first time in record.
              foreach ($this->creditors_model->get_creditor($UniqContactID)->result_array() as $keyname => $cred)
              {
                //Break the data into individual fields
                $data['CategoryID'] = $cred['CategoryID'];
                $data['Company'] = $cred['Company'];
                $data['SearchName'] = $cred['SearchName'];
                $data['Building'] = $cred['Building'];
                $data['StreetNumber'] = $cred['StreetNumber'];
                $data['Unit'] = $cred['Unit'];
                $data['StreetNumberSuffix'] = $cred['StreetNumberSuffix'];
                $data['StreetName'] = $cred['StreetName'];
                $data['StreetType'] = $cred['StreetType'];
                $data['StreetDirection'] = $cred['StreetDirection'];
                $data['Municipality'] = $cred['Municipality'];
                $data['ProvinceState'] = $cred['ProvinceState'];
                $data['PostalCodeZip'] = $cred['PostalCodeZip'];
                $data['Country'] = $cred['Country'];
                $data['LTCCode'] = $cred['LTCCode'];
                $data['GovernmentCode'] = $cred['GovernmentCode'];
                $data['PrivacyPolicyExempt'] = $cred['PrivacyPolicyExempt'];
                $data['ProofOfClaimRequired'] = $cred['ProofOfClaimRequired'];
                $data['AdditionalInformation'] = $cred['AdditionalInformation'];            
              }

            $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.
                
            }
            
        };
    
    }

A short clip of the view (unchanged from before):

<li><label for="Company">Company:</label>
&lt;input type="text" name="Company" value="&lt;div style="border:1px solid #990000;padding-left:20px;margin:0 0 10px 0;">

<h4>A PHP Error was encountered</h4>

<p>Severity: Notice</p>
<p>Message: Undefined variable: Company</p>
<p>Filename: views/creditor_edit_view.php</p>

<p>Line Number: 58</p>

</div>Test Company Name" /></li>

--
Still scratching my pounding head. I appreciate you taking the time to look this over.


Messages In This Thread
Edit, validate, re-edit issue using set_value with optional parameter - by El Forum - 03-19-2010, 08:16 AM



Theme © iAndrew 2016 - Forum software by © MyBB