I have a one to many relationship and the problem is that how do I show that to user ?
For eg a user can have many alias and he should be able to create as many alias as he wants to. I am having problem in finding out how to make user input as many values as he wants and then add them to db.
For the recommendation below, I assume you have a separate table that holds the aliases and links back to your user table.
[*]You can start by using a JS library like select2 (ivaynberg.github.io/select2/#tags) and give users the ability to keep adding aliases (referred to as tags in select2).
[*]You can convert your model from CActiveRecord to ManyManyActiveRecord (class found at github.com/hastenax/yii-cmanymanyactiverecord). This will allow you to do things like link one user ID to an array of alias IDs in one $model->setRelationRecords() call.
[*]On form submit, use your controller action to call $model->setRelationRecords() before calling $model->save().
This is a fully fleshed out solution, but it should guide you in the right direction. Note that I’ve used something similar in a project of mine.