Model Is Not Set (Actioncreate)

Hello. I have 3 database tables:



tbl_observation(id, name, city_id)

I’ve 3 models too and defined relations:

City('idCommune' => array(self::BELONGS_TO, 'Commune', 'commune_id'),

Commune(without defined relations)

Observation('idCity' => array(self::BELONGS_TO, 'City', 'city_id').

In my _form view i’ve got this textFieldRow:


When i try to edit my observation everything works fine, but when i try to create new observatoins i’ve got this error:

TbInput: Failed to initialize widget! Model is not set. 

I think that this error is caused, because when i try to create a new observation my _form view try to load Commune name, but it’s empty. Can you help me with this?

Sorry for my english :)





It doesn’t work :(

same problem here

so i have passed two models in actionCreate()


and it works fine !!!

Here is my full actual code, if anyone could look at this…Thanks

did You pass $commune to the form ?

show how You render _form in your view.