I was wondering if there is another way more “cakephp like” to insert the user_id in multiple insert on the same Table. Example of what I do :
$user_id = $this->Auth->user('id');
if ($this->request->is('post')) {
foreach ($this->request->data['Post'] as $key => $value) {
if (is_int($key)) {
$this->request->data['Post'][$key]['user_id'] = $user_id;
}
unset($key);
unset($value);
}
debug($this->data['Post']);
die();
$this->Post->saveAll($this->data['Post']);
}
I don’t use input hidden value user_id for serurity reason.
Thanks for your help !
Try something like this: