Skip to main content

This site requires you to update your browser. Your browsing experience maybe affected by not having the most up to date version.

General Questions

General questions about getting started with SilverStripe that don't fit in any of the categories above.

Moderators: martimiz, Sean, biapar, Willr, Ingo, swaiba, simon_w

Autopopulate Date


Reply

5 Posts   786 Views

Avatar
headless_pnub

12 March 2009 at 6:41am Community Member, 17 Posts

Hi all,

I'm looking to have the date automatically added to the field when a new news item is created just in case I have any lazy users who don't bother or forget.

Is this possible/can you give me a clue?

Thanks in advance,
Pnub

Avatar
Ben Gribaudo

12 March 2009 at 7:26am Community Member, 181 Posts

Hi Pnub,

Does populateDefaults() do what you want?
http://doc.silverstripe.org/doku.php?id=recipes:populatedefaults

Ben

Avatar
headless_pnub

13 March 2009 at 3:11am Community Member, 17 Posts

Hi Ben,

Thanks, that does look like what I want. Hope would I implement that? ie: where would i put the code?
Thanks again,

Pnub

Avatar
Ben Gribaudo

13 March 2009 at 3:58am Community Member, 181 Posts

Hi Pnub,

Try placing it in your news item class.

Ben

Avatar
headless_pnub

13 March 2009 at 5:06am Community Member, 17 Posts

Brilliant, thank you so much.