CakePHP 2 – Tip#2: Saving Data via Hidden Field in View

If your trying to save the a foreign key of something heres how you can do it. Eg you want to save the user_id to the products table but you dont want the user to be able to input the user id as there all ready logged in;

In the your view add this line;

echo $this->Form->hidden('user_id', array('value' =>AuthComponent::user('id')));