File tree Expand file tree Collapse file tree 3 files changed +9
-17
lines changed
Expand file tree Collapse file tree 3 files changed +9
-17
lines changed Original file line number Diff line number Diff line change @@ -22,7 +22,7 @@ trait ValidatorTrait {
2222 private function callback ($ closure = null )
2323 {
2424 if (Tame::isClosure ($ closure )){
25- return $ closure ($ this );
25+ return $ closure ($ this );
2626 }
2727 }
2828
Original file line number Diff line number Diff line change @@ -122,37 +122,29 @@ public function validate($closure = null)
122122
123123 /**
124124 * Form save response
125- *
125+ *
126126 * @param Closure $function
127127 * @return mixed
128128 */
129129 public function save ($ closure )
130130 {
131- // if validation already failed, send stored JsonResponse now
131+ // if validation already failed, return stored JsonResponse
132132 if (ValidatorMethod::isJsonResponse ($ this ->jsonResponse )) {
133- // Send headers/body only once and return response for frameworks/tests
134- if (!$ this ->responseSent ) {
135- $ this ->jsonResponse ->send ();
136- $ this ->responseSent = true ;
137- }
138133 return $ this ->jsonResponse ;
139134 }
140135
141136 if ($ this ->isValidated ()){
142-
137+
143138 // save into a remembering variable
144139 ValidatorMethod::resolveFlash ($ this );
145-
140+
146141 $ response = $ this ->callback ($ closure );
147142
148- // If user returns a JsonResponse in save, send and return it
143+ // If user returns a JsonResponse in save, return it
149144 if (ValidatorMethod::isJsonResponse ($ response )) {
150- if (!$ this ->responseSent ) {
151- $ response ->send ();
152- $ this ->responseSent = true ;
153- }
145+ return $ response ;
154146 }
155-
147+
156148 // delete csrf session token
157149 CsrfToken::unsetToken ();
158150 }
Original file line number Diff line number Diff line change 1616 "enum:terms " => 'Accept terms and condition ' ,
1717])->validate (function ($ response ){
1818
19- return $ response ->json (1 , $ response ->message );
19+ // return $response->json(1, $response->message);
2020
2121 var_dump (
2222 $ response ,
You can’t perform that action at this time.
0 commit comments