i should be able to view the user with it’s first name and last name and also should be able to update it from user edit screen.
can any one guide me how to do this so I can update 2 models from one form as the auto generated CRUD using gii allows me to display and edit one model only?
So, if I understand, on form submission you’re trying to save one record in the user table, two records in the user_profile_type table and two rows in the user_profile table?
Although I think that can be done I think it would be rather awkward. I would question whether you are approaching the application requirements the right.
And handle them from there following the example in the link earlier but manually setting the attributes.
$user_profile = new UserProfile;
$user_profile->first_name = Yii::app()->getRequest()->getParam('user_profile')['first_name'];
$user_profile->last_name = Yii::app()->getRequest()->getParam('user_profile')['last_name'];
I think that’s it. I haven’t tested it.
Is there a good reason that you don’t have first name and last name in the user_profile table? or at least have them both in one other table as two different fields?
I am trying to build generic model so i can add new profile field in user_profile_type which will be referred by user_profile table which hold uid and user_profile_type->id and value for that record.