I have a cakephp application in which the Payments table has many applications,
I am trying to save with the code below, but the payment data is not being saved, only the application data is being saved.
public function add()
{
$application = $this->Applications->newEntity();
if ($this->request->is('post')) {
$application = $this->Applications->patchEntity($application, $this->request->getData(),
[ 'associated'=>['Payments'] ]);
//debug($application);
//exit;
if ($this->Applications->save($application)) {
$this->Flash->success(__('The application has been saved.'));
//debug($application);
//exit();
return $this->redirect(['action' => 'view', $application['id']]);
}
$this->Flash->error(__('The application could not be saved. Please, try again.'));
}
$tasks = $this->Applications->Tasks->find('list', ['limit' => 200]);
$this->set(compact('application', 'tasks'));
}
Please what could be wrong?
\src\Controller\ApplicationsController.php (line 58)
[
'tasks_id' => '5',
'refnumber' => '1519062454350860',
'payment' => [
(int) 0 => [
'refnumber' => '1519062454350860'
]
],
'surname' => 'asdf',
'othernames' => 'Opeoluwa Clement',
'gender' => 'male',
'phone' => '08060595019',
'email' => '[email protected]',
'canid' => 'asdfasd',
'examinationpassed' => 'Post Fellowship Certificate',
'monthofexaminationpassed' => 'April',
'yearofexaminationpassed' => '1950',
'transcriptaddress' => 'Lagos State University',
'status' => 'Opened',
'applicationletter' => [
'tmp_name' => 'C:\wamp\tmp\php69B1.tmp',
'error' => (int) 0,
'name' => 'OAGCOurse.jpg',
'type' => 'image/jpeg',
'size' => (int) 189739
],
'postinglog' => [
'tmp_name' => 'C:\wamp\tmp\php69E1.tmp',
'error' => (int) 0,
'name' => 'OAGCOurse.jpg',
'type' => 'image/jpeg',
'size' => (int) 189739
],
'certificate' => [
'tmp_name' => 'C:\wamp\tmp\php6A11.tmp',
'error' => (int) 0,
'name' => 'OAGCOurse.jpg',
'type' => 'image/jpeg',
'size' => (int) 189739
],
'evidenceofpayment' => [
'tmp_name' => 'C:\wamp\tmp\php6A41.tmp',
'error' => (int) 0,
'name' => 'OAGCOurse.jpg',
'type' => 'image/jpeg',
'size' => (int) 189739
],
'annualdues' => [
'tmp_name' => 'C:\wamp\tmp\php6A70.tmp',
'error' => (int) 0,
'name' => 'OAGCOurse.jpg',
'type' => 'image/jpeg',
'size' => (int) 189739
]
]
Warning (2): mb_strlen() expects parameter 1 to be string, array given [CORE\src\Validation\Validation.php, line 742]
\src\Controller\ApplicationsController.php (line 59)
object(App\Model\Entity\Application) {
'tasks_id' => (int) 3,
'surname' => 'clement',
'othernames' => 'Opeoluwa Clement',
'gender' => 'female',
'phone' => '08060595019',
'email' => '[email protected]',
'canid' => 'asdfasd',
'examinationpassed' => 'Part 1/Membership',
'transcriptaddress' => 'Lagos State University',
'status' => 'Opened',
'applicationletter' => [
'tmp_name' => 'C:\wamp\tmp\php7E70.tmp',
'error' => (int) 0,
'name' => 'fav.png',
'type' => 'image/png',
'size' => (int) 13893
],
'postinglog' => [
'tmp_name' => 'C:\wamp\tmp\php7E90.tmp',
'error' => (int) 0,
'name' => 'fav.png',
'type' => 'image/png',
'size' => (int) 13893
],
'certificate' => [
'tmp_name' => 'C:\wamp\tmp\php7ED0.tmp',
'error' => (int) 0,
'name' => 'fav.png',
'type' => 'image/png',
'size' => (int) 13893
],
'evidenceofpayment' => [
'tmp_name' => 'C:\wamp\tmp\php7EFF.tmp',
'error' => (int) 0,
'name' => 'OAGCOurse.jpg',
'type' => 'image/jpeg',
'size' => (int) 189739
],
'annualdues' => [
'tmp_name' => 'C:\wamp\tmp\php7F4F.tmp',
'error' => (int) 0,
'name' => 'OAGCOurse.jpg',
'type' => 'image/jpeg',
'size' => (int) 189739
],
'[new]' => true,
'[accessible]' => [
'surname' => true,
'othernames' => true,
'gender' => true,
'email' => true,
'phone' => true,
'examinationpassed' => true,
'canid' => true,
'transcriptaddress' => true,
'applicationletter' => true,
'postinglog' => true,
'certificate' => true,
'evidenceofpayment' => true,
'annualdues' => true,
'tasks_id' => true,
'status' => true,
'modified' => true,
'created' => true,
'task' => true
],
'[dirty]' => [
'tasks_id' => true,
'surname' => true,
'othernames' => true,
'gender' => true,
'phone' => true,
'email' => true,
'canid' => true,
'examinationpassed' => true,
'transcriptaddress' => true,
'status' => true,
'applicationletter' => true,
'postinglog' => true,
'certificate' => true,
'evidenceofpayment' => true,
'annualdues' => true
],
'[original]' => [],
'[virtual]' => [],
'[errors]' => [],
'[invalid]' => [],
'[repository]' => 'Applications'
}