Jump to:

3460 Posts in 1064 Topics by 739 members

Data Model Questions

SilverStripe Forums » Data Model Questions » Writing Custom Data to fields onWrite

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

Page: 1
Go to End
Author Topic: 1233 Views
  • Patrick Arlt
    Avatar
    Community Member
    15 Posts

    Writing Custom Data to fields onWrite Link to this post

    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?

  • Willr
    Avatar
    Forum Moderator
    5508 Posts

    Re: Writing Custom Data to fields onWrite Link to this post

    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.

    1233 Views
Page: 1
Go to Top

Want to know more about the company that brought you SilverStripe? Then check out SilverStripe.com

Comments on this website? Please give feedback.