gavin1420 / yii-user

Automatically exported from code.google.com/p/yii-user
0 stars 0 forks source link

New profile field not saving when Save() called on User model #112

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?
--------------------------------------
1. Add a new Profile field
2. In any controller get the User model (e.g. $userMod = 
Yii::app()->getModule('user')->user(); )
2. Now in the controller, make a change to the new profile field created in 
step 1. (e.g. $userMod->profile->newField = 5).
3.Call the model save() function on the model. (i.e. $userMod->save(); )

What is the expected output? What do you see instead?
-----------------------------------------------------
The changed model data should be persisted to the database.
Instead, success is returned from the save() operation and the database is not 
updated.

What version of the product are you using? On what operating system?
--------------------------------------------------------------------
0.3 Yii:User, Yii 1.1.8 on CentOS 5.6

Please provide any additional information below.
------------------------------------------------
I want to add a new field to the profile and be able to update the value of 
this field from within my controllers.

Original issue reported on code.google.com by markk...@gmail.com on 21 Sep 2011 at 6:40

GoogleCodeExporter commented 9 years ago
OK. This maybe due to my lack of Yii experience, but I think this issue is due 
to lazy loading of related tables.

To get around it, you can manually load the Profile model in the controller and 
work with it just like any other.

e.g.
$profile = Profile::model->find(...);
do stuff to $profile....
$profile->save();

Original comment by markk...@gmail.com on 21 Sep 2011 at 10:01