public function encode($result)
    {
        if ('form' == $this->type) {
            array_walk_recursive($result[0], array($this, 'utf8'));
            
            $response = new SfResponse("<html><body><textarea>".json_encode($result[0])."</textarea></body></html>");            
            $response->headers->set('Content-Type', 'text/html');
            
            return $response;
        } else {
            if ($this->responseEncode){
                // @todo: check utf8 config option from bundle
                array_walk_recursive($result, array($this, 'utf8'));
            }

            $response = new SfResponse(json_encode($result));            
            $response->headers->set('Content-Type', 'application/json');
            
            return $response;
        }
    }