Manage two table's data in form

I am working on YII framework, and i am a newbie. I have user register form as shown below:

Username: [Textbox]

Email: [Textbox]

Address: [Text area]

User Loan Type: (Checkbox list as below)

Loan Type 1


Loan Type 2


Loan Type 3


Loan Type 4


Loan Type 5

Status [yes/no]

Now i have 3 models:

  1. User (for user data)

  2. LoanType (just for loan type list)

  3. UserLoanType (mapping between user and loan type)

All 3 models have HAS_MANY and BELONGS_TO relations as we generally do in YII.

Now when user click on register button i want to save data in user_loan_type table as well. I can simply add core php logic in actionCreate. But is there any standard YII practice for this?? Because i need validation, remain form selected during edit etc. Can anyone guide me how to do this? Or point me any example link, i have googled but did’t help.

Thanks.

checkout this page

how-to-use-a-single-form-to-collect-data-for-two-or-more-models

Thanks ahb.

Finally i found solution from http://www.yiiframework.com/forum/index.php/topic/16936-many-to-many

Hi Vibhaj,

I would like to manage in a single form data from 2 related tables. Does the solution you found work for ‘one to many’ relations? I have spent hours to find a solution. I am trying to use tabularinputmanager: it works rather fine with the actionCreate but I would like to do more with it, for example with the actionUpdate as well and I am finding it a bit difficult to understand. I am new to PHP and newer still to Yii. Can you please advise me? Thanks