How to save only modified fields

Hey there!

How do I save only modified fields ? I mean, i have a form (the same for inserting, im using the default generated CRUD), so if the users leave a field blank, it should not update that field. In my case I also have two comboboxes that has a value=0 option, and it should not save those too. If there’s no modified field, so it leaves the record without any changes. How do I do that?

Thanks in advance

No one?

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

Look at the second parameter. But you have to generate it manually.

Is this the only possibility, to set the ‘attributes’ property manually? In Propel you haven’t to do this.

Try to search the forums, there has been a similar discussion some months ago. And not sure, there might even be an extension doing that. The main principle is: After loading a record (afterFind()) you have to copy the attributes (e.g. to private array in the record) in order to find out, which of them have changed when you want to save the record again.