Handling variable number of inputs
Sometimes an application requires a form with variable number of inputs. For example, a task management application can provide a screen where you can add one or more tasks to your task list. An example of such an application is shown in the following screenshot:

By default, the page will display one task and two buttons: Add task, which will add another empty task, and Save, which will reload a form with all the tasks added. Let's check how we can solve this.
Getting ready
Create a fresh application using yiic webapp.
How to do it...
For our example, we will not save any data into the database. Instead, we will learn how to get a form with a variable number of fields up and running, and how to collect data submitted with it.
We will start with the
Taskmodel (protected/models/Task.php). As we agreed not to use database,CFormModelwill be enough as a base class:<?php class Task extends CFormModel { public $title; public $text; public function rules...