Formatting fields before view / after save


I have a date field stored as a timestamp in the database. How can I format the field before I present it in the view? Particularly if I'm using the cHtml::activeTextField.

I've reverted to not using the activeTextField and I'm just using standard html within the view so I can format the value of the field. This is obviously not as neat.

Similarly is the best way to format fields before saving to use the beforeSave function? if so what if you would like to do a variety of things before you save depending on which action is being called. Seems limiting to have only one place to make changes - and presumably the beforeSave function gets filled with things like :

if (this action) do this

else if (that action) do that

Seems again a little messy…

Any thoughts/advice greatly appreciated :)

Hi jdelight,

i think this thread is what you are looking for: http://www.yiiframew…pic,1179.0.html

Fantastic thanks :)