Custom Fields in Model

Hi Guys,

I wanted to design a Model where few static fields are already defined, and there is a Model CustomFields which allows to create custom fields with which Model to Use (Reference), type of a filed and Name.




class CustomFields extends CActiveRecord {

    public $id;

    public $model; //UserPersonal, UserContact etc.

    public $name; //Name of Field e.g. Party Animal?

    public $required; // True or False

    public $type; //Text, TextArea, Date, Select etc.

    public $options; // Depends on Field type i.e. null for Text and comma separated values for Select, Radio etc.


    public function rules()

    {

        return array(

            array('id, model, name, type','required'),

        );

    }

}


class UserPersonal extends CActiveRecord {

    public $id;

    public $user_id;

    public $firstname;

    public $lastname;

    .

    .

    .

    public $dob;


    public function rules()

    {

        return array(

            array('id, user_id, firstname, lastname','required'),

        );

    }

}



Now what I want is to add records created using CustomFields in respective models i.e. I will call CustomFields with attribute model as UserPersonal and will fetch rows accordingly. All these fields will receive input and will be stored in UserPersonal AR.