Yii Framework Forum: Model Is Not Set (Actioncreate) - Yii Framework Forum

Jump to content

Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

Model Is Not Set (Actioncreate) Rate Topic: -----

#1 User is offline   tzoll 

  • Junior Member
  • Pip
  • Yii
  • Group: Members
  • Posts: 74
  • Joined: 28-February 13

Posted 17 March 2013 - 11:26 AM

Hello. I have 3 database tables:
tbl_city(id,name,commune_id)
tbl_comune(id,name)
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:
$form->textFieldRow($model->idCity->idCommune,'name');?>

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 :)
Thanks.
Greetings
Tom
0

#2 User is offline   yiiplayboy 

  • Junior Member
  • Pip
  • Yii
  • Group: Members
  • Posts: 56
  • Joined: 03-May 12

Posted 19 March 2013 - 03:02 AM

View Posttzoll, on 17 March 2013 - 11:26 AM, said:

Hello. I have 3 database tables:
tbl_city(id,name,commune_id)
tbl_comune(id,name)
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:
$form->textFieldRow($model->idCity->idCommune,'name');?>

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 :)
Thanks.
Greetings
Tom



$form->textFieldRow($myCommuneModelName,'name');

0

#3 User is offline   tzoll 

  • Junior Member
  • Pip
  • Yii
  • Group: Members
  • Posts: 74
  • Joined: 28-February 13

Posted 19 March 2013 - 05:03 AM

View Postyiiplayboy, on 19 March 2013 - 03:02 AM, said:

$form->textFieldRow($myCommuneModelName,'name');



It doesn't work :(
0

#4 User is offline   Lal Zada 

  • Standard Member
  • PipPip
  • Yii
  • Group: Members
  • Posts: 125
  • Joined: 06-November 12
  • Location:Lahore, Pakistan

Posted 19 March 2013 - 06:06 AM

same problem here

so i have passed two models in actionCreate()
$form->textFieldRow($model2,'name');

and it works fine !!!

Is it fast? Is it secure? Is it professional? Is it right for my next project? Yes, it is

Linkedin Facebook Twitter Google+
0

#5 User is offline   tzoll 

  • Junior Member
  • Pip
  • Yii
  • Group: Members
  • Posts: 74
  • Joined: 28-February 13

Posted 19 March 2013 - 06:34 AM

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

http://pastebin.com/MuESVWsQ
0

#6 User is offline   mirunho 

  • Standard Member
  • PipPip
  • Yii
  • Group: Members
  • Posts: 170
  • Joined: 19-December 12
  • Location:Gdansk, Poland

Posted 19 March 2013 - 08:26 AM

View Posttzoll, on 19 March 2013 - 06:34 AM, said:

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

http://pastebin.com/MuESVWsQ

did You pass $commune to the form ?
show how You render _form in your view.
0

Share this topic:


Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

1 User(s) are reading this topic
0 members, 1 guests, 0 anonymous users