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