How do you get the string value of a MongoID using PHP?
Believe this is what you're after.
$widget['_id']->{'$id'};
Something like this.
$widget = array('text' => 'Some text');
$this->mongo->db->insert($widget);
$widget['widgetId'] = $widget['_id']->{'$id'};
echo json_encode($widget);
You can also use:
(string)$widget['_id']