Skip to content Skip to sidebar Skip to footer

Cakephp Associations Error? Won't Save Associated Table

I created a user profile where users can add their information. So on URL section I want them to put their other links like Facebook, www.facebook.com/user etc. But when I click Sa

Solution 1:

You are trying to Associated model's data. And your primary Model does not have data to save.

You can take two approaches here,

  1. Your present way, take User's info and have them provide UserWeb information from the same form. The use will provide the information as a part of registration. For this you should refer to Saving Associated model data - saveAll()

  2. Second way, have user provide their info during registration and let them add UsersWeb later. (by later I mean user's can update it during registration as well but not in same form). For this use UserWeb. Have the same form appear from /yourapp/UsersWebs/add. You will have to provide the user_id. This will be more refined.

P.S: I strongly recommend you to go through Saving your data again. It will hardly take you 10 mins, I am sure you have done this before but sparing another 10 mins after having encountered the issue will help you understand these things as back of your hand.

Post a Comment for "Cakephp Associations Error? Won't Save Associated Table"