开发者

Set default date for created_at and updated_at fields in a Doctrine form

开发者 https://www.devze.com 2022-12-28 19:47 出处:网络
I have a symfony form which have crea开发者_开发问答ted_at and updated_at field for date. But I want to populate this field with default value and not shown when the form shows. So that, the created_a

I have a symfony form which have crea开发者_开发问答ted_at and updated_at field for date. But I want to populate this field with default value and not shown when the form shows. So that, the created_at will hold the current time when inserting new data and updated_at will hold current date when updating any data.


These fields are automatically handled by propel. Simply unset() the fields in the form, and let propel do the magic :)

If you're using doctrine, add the Timestampable behavior to your class and unset the fields in the form, and it'll work too.

0

精彩评论

暂无评论...
验证码 换一张
取 消