Yii Framework Forum: Forms of 2 models in one form - Yii Framework Forum

Jump to content

Page 1 of 1
  • You cannot start a new topic
  • This topic is locked

Forms of 2 models in one form Rate Topic: -----

#1 User is offline   mithila 

  • Standard Member
  • PipPip
  • Yii
  • Group: Members
  • Posts: 116
  • Joined: 18-April 11

Posted 01 June 2011 - 09:13 AM

Hi all,


I have 2 seperate models models1 and model2. What i want to know is, is it possible to have the forms of both those models combined in one form and then save their values individually?If so how do i go about this?
0

#2 User is offline   Maurizio Domba Cerin 

  • Yii - Yesss It Is !!!
  • Yii
  • Group: Yii Dev Team
  • Posts: 4,355
  • Joined: 12-October 09
  • Location:Croatia

Posted 01 June 2011 - 04:14 PM

Start by reading this wiki - http://www.yiiframew...-or-more-models
Find more about me.... btw. Do you know your WAN IP?
0

#3 User is offline   mithila 

  • Standard Member
  • PipPip
  • Yii
  • Group: Members
  • Posts: 116
  • Joined: 18-April 11

Posted 02 June 2011 - 12:14 AM

hi mdomba,

thanks for the reply. What you said has to be done in the controller but what i want to know is how do i combine the 2 forms inside one form and display it?
Please help me..


Thanks
0

#4 User is offline   Maurizio Domba Cerin 

  • Yii - Yesss It Is !!!
  • Yii
  • Group: Yii Dev Team
  • Posts: 4,355
  • Joined: 12-October 09
  • Location:Croatia

Posted 02 June 2011 - 01:36 AM

Have you read the wiki?

If yes... do you understand that you can create two models and send them both to the view with
$this->render('create',array(
   'model1'=>$model1,
   'model2'=>$model2
));


Now in the view you have 2 models: $model1 and $model2... and you can create input fields for both of them...
Find more about me.... btw. Do you know your WAN IP?
1

#5 User is offline   Maurizio Domba Cerin 

  • Yii - Yesss It Is !!!
  • Yii
  • Group: Yii Dev Team
  • Posts: 4,355
  • Joined: 12-October 09
  • Location:Croatia

Posted 02 June 2011 - 03:39 AM

NOTE: you posted in the Yii 1.0 sub.forum... do you use this version ?
Find more about me.... btw. Do you know your WAN IP?
0

#6 User is offline   Vataraxia 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 11
  • Joined: 27-June 12
  • Location:Jakarta

Posted 12 July 2012 - 09:08 PM

hi, i want to ask u, i want to save one textfield into two different table, how can i do that?
Where there's a will, there's a way
1

Share this topic:


Page 1 of 1
  • You cannot start a new topic
  • This topic is locked

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