I am using cake php 3 version. I try to insert data into db but inserting null values. I check so many ways i couldn’t find the issue: This is is my controller code
if ($this->request->is(‘post’)) {
$expense = $this->Expenses->newEntity();
$expense = $this->Expenses->patchEntity($expense,$this->request->getData());
echo "<pre>";print_r($expense); die;
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 {
print_r($expense->errors()); die;
//$this->Flash->error(__('The {0} could not be saved. Please, try again.', 'Expense'));
//}
}
}
The entity you show does have 2 values patched onto it and they are the only two values you allow (through ‘accessible’). But there is a lot that is unknown here.
what type is msinumber? in the entity looks like it might be a string but has no quotes.
is this match to the record that made the record image you included in your question? In that msi_index does not exist but `msiindex does.
are these two values the only ones you tried to patch?
we can assume this entity is ‘after patch’. It shows no validation errors, but are there any validations set for this enitity? If not, it might patch just like this but still fail to save because of some column-type or constraint problem. I’m not 100% sure, but I think the after-save entity might also show errors specific to the save.
Bottom line, there is just too much ambiguity here to say much more about what might be happening.