Hi all, I have a symfony form which have created_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. Did anyone do something like this? Looking for help on google all the morning but didnt find any. Can anyone help me out there? Pleaseeeeeeee...
views:
355answers:
1
+1
A:
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.
Maerlyn
2010-05-03 19:47:19
but i am using doctrine, should doctrine also do the magic?
sparrow
2010-05-03 19:48:36
I'm a propel guy, but as far as I can tell reading the Timestampable behavior's documentation, yes. See http://www.doctrine-project.org/documentation/manual/1_2/en/behaviors#core-behaviors:timestampable
Maerlyn
2010-05-03 21:00:38
@sparrow, @maerlyn is right — you just have to unset these fields and Timestampable template will do the job for you. I'm fellow Doctrine user for last 1.5 years :)
develop7
2010-05-03 22:04:55
@maerlyn, how about updating your answer so @sparrow could mark it as right one?
develop7
2010-05-03 22:06:43
@all, thanks for helping. yes it worked also for doctrine. what i have learnt here is the created_at and updated_at must be created by symfony by actAs: Timestampable, not by hand directly in database. Thanks a lot again to all.
sparrow
2010-05-04 02:36:16
Timestampable behavior works both using Doctrine or Propel, 100% guaranted !
Clement Herreman
2010-05-07 07:27:30