Active record optional fields breaking queries

Hi

I am new to Yii and overall love the approach of the code generator for the whole MVC stack. However, I have a pretty basic requirement; I have a form that has an optional field ‘price’ into which the user can optionally enter a number. If the user enters nothing into that form field activeRecord tries to insert an empty string into an float field and the whole thing blows up. I imagine there must be a really easy way (maybe through model rules) to only insert/update a field if the user has entered something that passes validation.

Any tips gratefully received.

I think the best place to take care of this is in the beforeSave method (convert to float 0.0)

http://www.yiiframework.com/doc/api/CActiveRecord#beforeSave-detail

/Tommy

Great, will try that, thanks.