解决方案如何在Yii Active Record中将数据保存/更新为少数表(模型)

I am new in Yii and Active Record and I want to ask you some solution how to do some things. I have 3 tables in db: car - info about cars, car_model - info about models of the cars, car__car_model - relation table, which binds this 2 tables in Many_to_Many relation - it has fileds - id_car,id_model,is_hidden,orderby.

Task is to show some (till 5) similar car models on car page.

i have a big form in which i enter information about car (car table), and i have 5 html blocks (5 rows in db in table car_model)with some input fields. Each block it is a row in car_model table - it contain fields: id_model - (primary key in car_model table), and some info fields which in this car_model table. Records in car_model table are always already exist, user just choose model_id in form and update this row and by checkbox he can do this relation hidden (is_hidden field) In other words, user just updates car_model table records and binds them to car table (car__car_model table). My question is following: how can i implement it, using activeFields and correct using Active Record ideology. Have any ideas?

I set up relation with this tables - and display this data with no problem - saving/updating data i implement using static content (Chtml) - set up static names for this html fields and in Controller i foreach this fields - but i think it is not correct

Image of this form: http://programmer.pp.ua/out/1.png

Tables:

car: id,other fields

car_model: id,other text fields which need to update

car__car_model:id_car,id_model,is_hidden(checkbox in form),orderby**

Relations in Car Model:

'carAdviceModel'=> array(self::HAS_MANY,'CarCarModel', 'id_car'),
'adviceModels'  => array(self::HAS_MANY, 'CarModel', 'id_model', 'through' => 'carAdviceModel'),

Thanks you in advance Sorry for my bad English - it is my first question here.

Ok, this is a bit odd, but maybe you want to send three models to the view, each an array of 5 models. The models can be brand new, or some can start out populated. Search the Yii definitive guide for 'Collecting Tabular Input'. It will give you everything you need to know about how to do this. You can validate all the models. You can also save all the models without having to validate them all again by using save(false).