I have two database table 1) users 2) profiles
profiles has a field called bank_ac
I am trying to save it from user model.
I have created form input like
<?= $this->Form->create($user) ?>
<?= $this->Form->control('profile.bank_ac'); ?>
<?= $this->Form->end() ?>
User model I have added associative like
$this->hasOne('Profiles');
After debug getting data like
[
'name' => 'Jone',
'email' => '[email protected]',
'profile' => [
'bank_ac' => '1212212'
]
]
after debug patch entity
object(App\Model\Entity\User) {
'name' => 'Jone',
'email' => '[email protected]',
'[new]' => true,
'[accessible]' => [
'name' => true,
'email' => true,
'created' => true,
'modified' => true
],
'[dirty]' => [
'name' => true,
'email' => true,
'profile' => true
],
'[original]' => [],
'[virtual]' => [],
'[hasErrors]' => false,
'[errors]' => [],
'[invalid]' => [],
'[repository]' => 'Users'
}
In UsersController/add I have applied code like
public function add(){
$user = $this->Users->newEmptyEntity();
$user = $this->Users->patchEntity($user, $this->request->getData());
$this->Users->save($user, ['associated' => ['Profiles']]);
}
Profile data not saving , also not getting any error. How can I save this associative data ?
$user
entity.