@@ -123,43 +123,32 @@ public function validate($closure = null)
123123
124124 /**
125125 * Form save response
126- *
126+ *
127127 * @param Closure $function
128128 * @return mixed
129129 */
130130 public function save ($ closure )
131131 {
132- // if validation already failed, send stored JsonResponse now
132+ // if validation already failed, return stored JsonResponse
133133 if ($ this ->jsonResponse instanceof \Symfony \Component \HttpFoundation \JsonResponse) {
134- // Send headers/body only once and return response for frameworks/tests
135- if (!$ this ->responseSent ) {
136- $ this ->jsonResponse ->send ();
137- $ this ->responseSent = true ;
138- }
139134 return $ this ->jsonResponse ;
140135 }
141136
142137 if ($ this ->isValidated ()){
143-
138+
144139 // save into a remembering variable
145140 ValidatorMethod::resolveFlash ($ this );
146-
141+
147142 $ response = $ this ->callback ($ closure );
148143
149- // If user returns a JsonResponse in save, send and return it
144+ // If user returns a JsonResponse in save, return it
150145 if ($ response instanceof \Symfony \Component \HttpFoundation \JsonResponse) {
151- if (!$ this ->responseSent ) {
152- $ response ->send ();
153- $ this ->responseSent = true ;
154- }
155- // return $response;
156-
157- var_dump (
158- 'sent method '
159- );
160- exit ();
146+ // delete csrf session token
147+ CsrfToken::unsetToken ();
148+
149+ return $ response ;
161150 }
162-
151+
163152 // delete csrf session token
164153 CsrfToken::unsetToken ();
165154 }
0 commit comments