Yii Framework Forum: Multiple CForms on a page with the same model class? - Yii Framework Forum

Jump to content

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

Multiple CForms on a page with the same model class? How do you do it? Rate Topic: -----

#1 User is offline   datashaman 

  • Junior Member
  • Pip
  • Yii
  • Group: Members
  • Posts: 56
  • Joined: 27-September 09
  • Location:Cape Town, South Africa

Posted 27 October 2009 - 06:56 AM

I'm struggling with a page which has multiple instances of CForm's with their own models. Problem is the models are all of the same class, so the generated IDs and Names are all duplicated as ClassName_Attribute and className[attribute]. From looking through the code, there does not seem to be a way to present more than 1 form on a page. I can't use subforms since I want to present the content in a tab view, and I'm not sure that would solve the problem anyway.

Any suggestions?
0

#2 User is online   qiang 

  • Yii Project Lead
  • Yii
  • Group: Yii Dev Team
  • Posts: 5,902
  • Joined: 04-October 08
  • Location:DC, USA

Posted 27 October 2009 - 07:42 AM

It should be fine you have duplicated input names. To avoid duplication of input IDs (because they violate XHTML), you may explicitly set them in each input element.
You should use different submit button name for different forms in order to load different sets of input data.
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