Skip to content

Commit 5fb46a1

Browse files
committed
minor #19328 Fix code example: replace request get() with all() method to support non-scalar types (alejgarciarodriguez)
This PR was merged into the 5.4 branch. Discussion ---------- Fix code example: replace request get() with all() method to support non-scalar types <!-- If your pull request fixes a BUG, use the oldest maintained branch that contains the bug (see https://symfony.com/releases for the list of maintained branches). If your pull request documents a NEW FEATURE, use the same Symfony branch where the feature was introduced (and `6.x` for features of unreleased versions). --> Method `$request->request->get` does not support non-scalar types so it won't work with forms since they are received as an array type. Using `get` used to work in older Symfony versions but no longer does, now an exception is thrown. IMO we should use `all` method instead in this example. Commits ------- 3a0df2b replace get() with all() method to support non-scalar types
2 parents 96552a3 + 3a0df2b commit 5fb46a1

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

form/direct_submit.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ control over when exactly your form is submitted and what data is passed to it::
1717
$form = $this->createForm(TaskType::class, $task);
1818

1919
if ($request->isMethod('POST')) {
20-
$form->submit($request->request->get($form->getName()));
20+
$form->submit($request->request->all($form->getName()));
2121

2222
if ($form->isSubmitted() && $form->isValid()) {
2323
// perform some action...

0 commit comments

Comments
 (0)