处理多个记录和模型使用Yii形式使用ajax形式 [英] Handling multiple records and models trought ajax in a form using Yii
问题描述
这是一个常见的情况:
在一个名为 Subscription 的表单中,我们还有其他订阅相关字段: / p>
选择您需要多少 foo :
选择包含从[1]到[5 ]
如果用户选择 2 ,则可以通过Ajax显示以下内容:
<! - for 1 - >
< input type =textid =name1>事物名称< / input>
< input type =textid =age1>事物的年龄< / input>
<! - for 2 - >
< input type =textid =name2>事物名称< / input>
< input type =textid =age2>事物的年龄< / input>
所以,我们有两个表(Subscription,foo),要插入其中一个的几个记录表(foo),所有这一切都在一个单一的表单上。
有没有人可以画一个快速的例子,我们应该如何正确地处理如上所述的场景?
我发现的更接近这个,但不包括多个模型和ajax。 :/
http://www.yiiframework.com/doc /guide/1.1/en/form.table
真的希望有人能给我一个推。
中,处理可变数量的输入
This must be a common scenario somehow:
On a form called Subscription we have, among other subscription related fields, this:
Select How many foo you need: Select box with 5 options from [1] to [5]
If the user selects 2 then, via Ajax the following should appear:
<!-- 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>
So, we have two tables (Subscription, foo), several records to be inserted on one of those tables (foo), all this on a single form.
Does anyone is kind enough to sketch a quick example on how should we properly deal with scenarios like the described above?
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
Really hope someone could give me a push here.
Have look at the chapter Handling variable number of inputs in the book Yii 1.1 Application Development Cookbook
这篇关于处理多个记录和模型使用Yii形式使用ajax形式的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!