Jump to:

23550 Posts in 19336 Topics by 2890 members

General Questions

SilverStripe Forums » General Questions » Debugging onBeforeWrite Issues

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

Page: 1
Go to End
Author Topic: 281 Views
  • zenmonkey
    Community Member
    528 Posts

    Debugging onBeforeWrite Issues Link to this post

    I have an onBeforeWrite that will work on new Page creation but not on resaving an existing page, can't figure out why

       function onBeforeWrite() {
          if ( is_null($this->Lat) || is_null($this->Lon) ) {
             $LatLon = Geocoder::Geocode($this->Address." ".($this->City()->Title == "Rural Communities" ? $this->Town : $this->City()->Title).", Ontario ".$this->PostalCode);
             if($LatLon) {
                $this->Lat = $LatLon["Lat"];
                $this->Lon = $LatLon["Lon"];


    I know on the resave the is_null fires true if the field is null, and if I check $this->Lat or $this->Lon before the parent::onBeforeWrite() does show the changed value but it doesn't make it the DB

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.