English 中文(简体)
使用 Yii 处理多种记录和模型
原标题:Handling multiple records and models trought ajax in a form using Yii

必须以某种方式将这种情景视为一种共同情景:

在一个名为“坚固”订阅 < /坚固 > 的表格上,我们除其他与订阅有关的领域外,还有:

Select How many foo you need: Select box with 5 options from [1] to [5]

如果用户选择了 < 坚固>2 ,则通过Ajax应显示以下内容:

<!-- for 1 -->
 <input type="text" id="name1">Name of thing</input>  
 <input type="text" id="age1">Age of thing</input>  

<!-- for 2 -->
 <input type="text" id="name2">Name of thing</input>  
 <input type="text" id="age2">Age of thing</input> 

因此,我们有两个表格(订阅、foo),几个记录将插入其中的一个表格(foo),所有这些都以单一表格形式。

有没有人愿意列举一个简单的例子,说明我们应如何妥善处理上述情况?

The closer that I found was this, but, doesn t cover multiple models nor ajax. :/ http://www.yiiframework.com/doc/guide/1.1/en/form.table

真希望有人能帮我推一下这里

最佳回答

请查看以下章节 < a href=> http://books.google.co.in/books? id=N94oPslruocC&pg=PT180&lpg=PT180&lpg=PT180#v=onepage&q&f=false” rel=“nofollow” >Handling 投入的变量数量 手册Yii 1. 1 应用程序开发库

问题回答

I m struggling with an analog problem at the moment. In general, I think you should be able to loop over the models. Every form, will have field names like: Object[$i][ number ] ($i = counter). The ajax request can be a render partial, I think, no?

如果我今晚找到它, 我会在这里张贴一些代码。





相关问题
Choosing the right subclass to instantiate programmatically

Ok, the context is some serialization / deserialization code that will parse a byte stream into an object representation that s easier to work with (and vice-versa). Here s a simplified example ...

Design pattern for managing queues and stacks?

Is there a design pattern for managing a queue or a stack? For example, we are looking to manage a list of tasks. These tasks will be added to a group queue, users will then be able to pull off the ...

Organizing classes using the repository design pattern

I have started upgrading one of our internal software applications, written in ASP.NET Web Forms, and moving to ASP.NET MVC. I am trying to leverage the Repository design pattern for my classes, ...

Misuse of Observer Pattern?

I have a Car object which contains a latitude field and a longitude field. I use the observer pattern so that any time either of these fields change in my application, my car object is notified. I ...

How are Models (in MVC) and DAOs supposed to interact?

How are models and DAOs supposed to interact? I m in the process of putting together a simple login module and I m unsure where to put the "business logic." If I put the logic with the data in the ...

热门标签