Saving data in multiple tables

if u trying to save for new record(s) u can follow to what annabel sugested,

but if u trying to update/edit record(s) along with associated data.

since the id field is protected by default inside the entity rule, (u can check the related model entity)
so you need to make the ids of associated data accessible.

example :

$this->Users->patchEntity($entity, $this->request->getData, [
‘associated’ => [
‘UserProfiles’ => [‘accessibleFields’ => [‘id’ => true]
]
]
]);

by this you don’t need hidden field for defining the IDs.

sorry for my bad english, hope this might help.