diff Lib/IMPL/Web/QueryHandler/JsonFormat.pm @ 173:aaab45153411

minor bugfixes
author sourcer
date Wed, 14 Sep 2011 18:59:01 +0400
parents 4267a2ac3d46
children d1676be8afcc
line wrap: on
line diff
--- a/Lib/IMPL/Web/QueryHandler/JsonFormat.pm	Mon Jun 20 23:42:44 2011 +0400
+++ b/Lib/IMPL/Web/QueryHandler/JsonFormat.pm	Wed Sep 14 18:59:01 2011 +0400
@@ -10,7 +10,6 @@
 	my ($this,$action,$nextHandler) = @_;
 	
 	my $result;
-	my $t = new IMPL::Transform::Json;
 	
 	try {
 		$result = $nextHandler->();
@@ -20,6 +19,15 @@
 		$result = { error => $err };
 	};
 	
+	my $t = new IMPL::Transform::Json($action->context->{json});
+	
+	if ($action->context->{transactionType} and $action->context->{transactionType} eq 'form') {
+		delete @$result{qw(formData formSchema)};
+		my $errors = @$result{formErrors};
+		
+		$result->{formErrors} = [ map $_->Message, @$errors ] if $errors;
+	}
+	
 	$action->response->contentType('text/javascript');
 	
 	my $hout = $action->response->streamBody;
@@ -41,6 +49,10 @@
 
 our %CTOR = (
 	'IMPL::Transform' => sub {
+		my $options = shift;
+		(
+			$options ? %{$options} : ()
+		),
 		ARRAY => sub {
 			my ($this,$object) = @_;