There is a problem I have with the Yii framework of which I can’t wrap my head around. The following is the case;
I have a ActiveRecord model with certain attributes. One of the attributes is a currency amount which is stored in the database in cents. Data entry however must take place in Dollars. When I use the ActiveForm and an activefields, the value of the fields is the entry in cents ofcourse.
Now what I want is that the value of the field is always displayed in Dollars and entered in Dollars, and stored in the database as cents. There are functions like afterFind but I think I can’t use this because it is always used not only with data display/entry in a form.
Does someone recognize this case and are there any best practices/solutions? Thanks.