Edit_account_data FORM MODEL

<?php
if ( ! defined('BASEPATH')) exit('No direct script access allowed');

class Account_changes extends CI_Model
{

	//Compulsory fetch data for template with default values from DB
	public function fetch_data($id, $activity){
		
		if($actvity->payload == null){ //why this condition? This condition is to get data only when the form is yet to be submitted and has to display contents from Database
		    $payload = new stdClass();
                    
                    //load from database
                    //payload->this->db->select()->where("");

                    //payload from exiting environment (from get_activity)
		    $payload->first_name = $activity->customer->first_name;
		    $payload->last_name = $activity->customer->last_name;
		}
		//pass activity data and act_data as payload
		$data = array(
			"activity" => $activity,	
			"act_data" => $payload	
		);
		
		return $data;
	}


        //Live data changes
        //This function is not necessary if you are using a process library as you would be loading it from the controller it self.
	public function update_accounts($id)
	{
		$data = $this->input->post();
		//insert data
		$insert_data = array(
			"first_name" => $data['first_name'],
			"last_name" => $data['last_name']
		);
		
		if($this->db->where("id",$id)->update("accounts",$insert_data)){
			return true;
		}else{
			return false;
		}
		
	}
	
	
	
}	

Back to: dev forms/develop custom forms