[looking for advice] should I override getAttributes?


I have been using Yii for 2 weeks now and I came across a problem where I save an attribute (member_ids) in a CActiveModel (called Team) but the member_ids are not in the Team database table. I looked in the Yii Api and the source code looked like it only gets column names. This confirms my suspicion: [forum post]yii does not return custom attributes by design

I am using the wizard-behaviour extension and I want to save the Team only at the very end of the wizard. I have 5 steps each with its own model and I would prefer not to treat this particular model as a special case in the wizardController but do the dirty work within the ActiveModel (Team).

When processing each step, I save the $_POST data in the $model->attributes. I am not sure if this is working, but I am confident that this gets save (I have set a safe rule for the attribute and the above referenced forum post says the safe rule works for setting custom attributes). The problem now is that to save the $_POST, I save it through $model->attributes, this uses the getAttributes function and thus my custom attribute (member_ids) is not getting saved. I could save the $_POST directly. The other problem is that my validation break, as I assume they use getAttributes aswell. I am worried that I will break other things if I override getAttributes. I read somewhere in the yii docs that overiding the getters and setters is almost always a bad idea.

Any advice would appreciated.


PS: as an aside, the bigger problem here is that I am trying to save Team members which have their own table. A Team has its propertities and many team members. I then override the AfterSave method to check if the member_ids attribute is empty, if its not empty, I loop through it saving members with proper team_id.

If there is a better way to do this without adding the TeamMembers model to the Team form (I feel the the team should know it has members) or which eliminates my getAttributes problem (I am wondering about Relational ActiveRecord), I would like to know it.