One form, two database tables, but how to solve with controllers/models?

I have a situation I wonder how to solve in Yii the best way. My scenario is this:

I have a form collecting data that will go into two (or more) db-tables.

As i understand, each AR is only for one db-table, so how would I solve this case?

I have thought out this possible solution, but would like comments before i pursue it further:

  • Make a model that extends CFormModel and has all the elements in my form. Then make a controller that uses sql queries to access the two different db-tables (or should I in the controller access two AR instead of sql?)

Quote

If the user input is collected, used and then discarded, we would create a form model; if the user input is collected and saved into database, we would use an active record instead.

Because of this text from the docs, something tells me I should make one AR for two db-tables, but doesnt that go against definition? …hmm

:)

maybe this would help?

http://www.yiiframew…oc/cookbook/19/

Hi, and thanks for the tip!

This looks like something yes, but tell me:

In the cookbook example he talks about two models, can I assume he is talking about AR type models (CActiveRecord) and not form models (extending CFormModel) ?