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.

Data Model Questions /

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

Writing Custom Data to fields onWrite


Go to End


2 Posts   2248 Views

Avatar
Patrick Arlt

Community Member, 15 Posts

15 April 2010 at 2:53pm

I have a page type of "Venue" setup with 2 fields "Address" which I want CMS Editors to input and "LatLong" which will store the latitudes and longitude of a Google Geocoding Request (this will be used to generate google maps later).

I would like this all to happen automatically whenever the page is saved and published from the CMS. Is this possible what functions/methods should I use?

I have dug around in the documentation and nothing seems to quite fit my needs.

Any suggestions?

Avatar
Willr

Forum Moderator, 5523 Posts

15 April 2010 at 4:35pm

Sounds like onAfterWrite() would work for that.

http://doc.silverstripe.org/doku.php?id=datamodel&s=onbeforewrite#onbeforewrite

Thats the onBeforeWrite() but there is also onAfterWrite() and events for your datamodel on most actions.