I create new fields from in db table. i try to insert the form data what happend new changes column not inserting? its only insert exiting column in db
Controller Code:
if ($this->request->is(‘post’)) {
list($this->request->data["msi_number"], $this->request->data["msi_index"]) = $this->genMsiNumber();
// echo "<pre>"print_r($check_value);die;
$this->request->data["createdon"] = date("Y-m-d H:i:s");
$this->request->data["order_date"] = $this->formatDate($this->request->data["order_date"], "m/d/Y", "Y-m-d");
$this->request->data["createdon"] = date("Y-m-d H:i:s");
$this->request->data["jcid"] = $jcid;
$this->request->data["jcnumber"] = "Not Valid";
$this->request->data["currency"] = "AED";
$this->request->data["tax"] = "5.00";
$this->request->data["updatedby"]= $this->request->getSession()->read('Auth.User')['id'];
//print_r($this->request->getData());exit;
$expense = $this->Expenses->patchEntity($expense, $this->request->getData());
// debug($this->request->data);
//echo "<pre>";print_r($expense); die;
// $expenseArray = array("msi_number" => $expense->msi_number, "msi_index" => $expense->msi_index) ;
if ($this->Expenses->save($expense)) {
echo "Save Successfully!";die;
/*$this->Flash->success(__('The {0} has been saved.', 'Expense'));
if($jcid > 0)
return $this->redirect(['action' => 'view/'.$jcid,'controller' => 'jobcard']);
return $this->redirect(['action' => 'index']);*/
}
else {
echo 1;die;
// print_r($expense->errors()); die;
//$this->Flash->error(__('The {0} could not be saved. Please, try again.', 'Expense'));
//}
}
Model Code:
Blockquote
protected $_accessible = [
'msi_number' => true,
'msi_index' => true,
'suppliers_id' => true,
'order_date' => true, New column
'empid' => true, // New Fileds
'jcid' => true, //This is old fileds
'jcnumber' => true, //This is old fileds
'ref_no' => true, // new fileds
/*'discount' => true,
'totalcost' => true,
'tax' => true,
'taxamt' => true,
'nettotal' => true,
'currency' => true,*/
'updatedby' => true, //Old column
'createdon' => true //Old column
];
}