I have been trying to get this reload to work in Revo 2.3.3 in a plugin that fires on OnDocFormSave, but it just doesn't reload the resource.
I am creating a value for a TV on save (getting Lat Long coords based on a provided address) and would like to have the field filled in after the doc is saved.
plugin code below
$eventName = $modx->event->name;
switch($eventName) {
case "OnDocFormPrerender":
//add custom CSS for the TV elements in the settings panel
$modx->regClientCSS(MODX_ASSETS_URL.'customizations/property.css');
break;
case "OnDocFormSave":
//make the GeoCode call and save result to the tv latlng
$addr = $resource->get('description');
if(!empty($addr)){
$url = 'http://maps.google.com/maps/api/geocode/json?sensor=false&address='.str_replace (" ", "+", urlencode($addr));
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
$response = json_decode(curl_exec($ch), true);
if ($response['status'] != 'OK') {
return 'geocode failed';
}
$geometry = $response['results'][0]['geometry'];
$lat = $geometry['location']['lat'];
$long = $geometry['location']['lng'];
$resource->setTVValue('latlng', $lat.', '.$long);
}
$cm = $modx->getCacheManager();
$cm->refresh();
break;
default:
break;
}
return;
The TV is saving as expected, it just would be a better user experience to have the page refresh with the values in place without a manual refresh.