Yii model and custom fields

Hi guys,

I’m creating a app where user will can create meta field to store data on database, this fields will receive different kinds of data, like dates or monetary values.

My initial idea to create this this fields is store in a database table (eg: meta_fields), the name, value and validations of this field.

After on the time of use it on app, I intend to extend the AR methods __get and __set to use the name field as a attribute.


If on my table meta_fields i have this values:


| id | name     | value      | validation          |


| 1  | money_en | $562,00    | some validation...  |


| 2  | date_crt | 2010-12-09 | some validation...  |


I intend to use in my views and controllers like it:

$model->money_en //will return $562,00

Now the questions are:

1 - How can I use this kind of fields to store values and recovery it?

2 - How can I use different validation kinds to this fields? Since I store the validations array as a serialized values on database?