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"];
}
}
parent::onBeforeWrite();
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