Multi Relations in a Form

Dear Friends,

I am currently using the Yii framework to develop a large scale data entry portal. To do this I have split the project into small pieces and I am currently developing the first few forms which consist of a user profile entry.

The user profile entry is split into multiple pages/views and the user’s details are split across those pages. The user record is only created on submission of the last page and before that it is passed across in sessions.

I have a ‘User’ model which deals with the profile forms, first part of the form worked fine because the attributes on that part all exist locally in the ‘User’ model. The user also has a relation called ‘phones’. These hold a list of ‘Phone’ models for the particular user, each ‘Phone’ model can be a different type (e.g. home, office & mobile) and holds an international dialing code, area code and number. I have created a widget called ‘PhoneInput’ that creates the input fields for all those values.

On my second page of the user profile I would like to do the following:

  • show inputs for home, office and mobile phones (but only the home phone is a required field, the rest are optional, however if the user starts to fill any of the optional fields then they should be validated)

  • save the entered phone numbers into the ‘phones’ relation for the user

I am struggling to structure this and would appreciate any guiding hands.

Thank you in advance for your replies.

Best regards,

Alex