onBeforeSaveEntry listener to add/modify data of some fields I'm trying to build my first, very simple, one file plugin.  I'm having difficulty with a basic task and I can't find any documentation to help me out. Keep in mind that there is no validation whatsoever, I'm just trying to get it to work first.

public function init()
{
    parent::init();
    craft()-&gt;on('entries.onBeforeSaveEntry', function(Event $event)
    {
        $entry = $event-&gt;params['entry'];
        $section = craft()-&gt;sections-&gt;getSectionById($entry['sectionId']);
        if ($section['handle'] == 'institutions')
        {
            $full_address = urlencode(rtrim($entry['adresse'].','.$entry['ville'].','.$entry['province'].','.$entry['codePostal']));
            $json = json_decode(file_get_contents("https://maps.googleapis.com/maps/api/geocode/json?address={$full_address}&amp;sensor=false&amp;region=ca&amp;key=AIzaSyDhPYj9UwwUYNZYSz9Fo-j75gCJKWVdFeY"));
            $entry-&gt;setRawPostContent('latitude' ,$json-&gt;results[0]-&gt;geometry-&gt;location-&gt;lat);
            $entry-&gt;setRawPostContent('longitude', $json-&gt;results[0]-&gt;geometry-&gt;location-&gt;lng);
        }
    });
}


I have a listener on entries.onBeforeSaveEntry and it works well.  I check if the section handle is what I need and then I look into the entry data to grab the address fields and query Google map.  All of that is working like a charm.

I can't figure out how to put the data back into the entry for the lat and long filed that exists in my entry type.  

$entry['latitude'] = $json-&gt;results[0]-&gt;geometry-&gt;location-&gt;lat;


That gives me an error saying latitude is not defined, which is false because I can output the value from it.

Also tried:

$entry-&gt;setRawPostContent('latitude' ,$json-&gt;results[0]-&gt;geometry-&gt;location-&gt;lat);


Any idea?  I can't find any documentation or google search that can help me out.
See Brandon's post on this here:
What is getContent() / the ContentModel, and how do I use it to get and set custom field values?

Basically when you're setting new custom field values, you should use setContentFromPost

$entry-&gt;setContentFromPost(array(
    'latitude' =&gt; $json-&gt;results[0]-&gt;geometry-&gt;location-&gt;lat,
);