Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit3db80ca

Browse files
committed
pass $data as second parameter
1 parent4b7271a commit3db80ca

File tree

2 files changed

+8
-6
lines changed

2 files changed

+8
-6
lines changed

‎src/Symfony/Bundle/FrameworkBundle/Controller/AbstractController.php‎

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -297,19 +297,21 @@ protected function stream(string $view, array $parameters = [], StreamedResponse
297297
* * if the form is submitted but invalid, $render is called and a 422 HTTP status code is set if the current status hasn't been customized
298298
* * if the form is submitted and valid, $onSuccess is called, usually this method saves the data and returns a 303 HTTP redirection
299299
*
300-
* @param callable(FormInterface): Response $onSuccess
301-
* @param callable(FormInterface): Response $render
300+
* @param callable(FormInterface, mixed): Response $onSuccess
301+
* @param callable(FormInterface, mixed): Response $render
302302
*/
303303
publicfunctionhandleForm(FormInterface$form,Request$request,callable$onSuccess,callable$render):Response
304304
{
305305
$form->handleRequest($request);
306306

307307
$submitted =$form->isSubmitted();
308+
309+
$data =$form->getData();
308310
if ($submitted &&$form->isValid()) {
309-
return$onSuccess($form);
311+
return$onSuccess($form,$data);
310312
}
311313

312-
$response =$render($form);
314+
$response =$render($form,$data);
313315
if ($submitted &&200 ===$response->getStatusCode()) {
314316
$response->setStatusCode(Response::HTTP_UNPROCESSABLE_ENTITY);
315317
}

‎src/Symfony/Bundle/FrameworkBundle/Tests/Controller/AbstractControllerTest.php‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -433,10 +433,10 @@ public function testHandleFormNotSubmitted()
433433
$response =$controller->handleForm(
434434
$form,
435435
Request::create('https://example.com'),
436-
function (FormInterface$form):Response {
436+
function (FormInterface$form,$data):Response {
437437
returnnewRedirectResponse('https://example.com/redir', Response::HTTP_SEE_OTHER);
438438
},
439-
function (FormInterface$form):Response {
439+
function (FormInterface$form,$data):Response {
440440
returnnewResponse('rendered');
441441
}
442442
);

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp