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.

We've moved the forum!

Please use forum.silverstripe.org for any new questions (announcement).
The forum archive will stick around, but will be read only.

You can also use our Slack channel or StackOverflow to ask for help.
Check out our community overview for more options to contribute.

General Questions /

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

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

autopopulate date


Go to End


2 Posts   1023 Views

Avatar
Arbee

Community Member, 31 Posts

15 October 2016 at 9:09am

I have a dataobject "workshop" where the content author adds the start date and several boxes on how many weeks each given lesson runs (these vary) along with a stop date (again number of weeks from start). Is there a way that I can autopopulate the dates for lessons and end once the information is entered?

Avatar
blackduck

Community Member, 13 Posts

24 October 2016 at 7:54pm

Hi Arbee,
This depends on what you're trying to achieve.
If the dates can always be calculated then you might want to not store them but instead use a function in your class to calculate on the fly.

If the dates need to be stored then using onBeforeWrite would let you set values.

https://docs.silverstripe.org/en/3.4/developer_guides/model/extending_dataobjects/