Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 4f1d4a8

Browse files
committed
Merge branch '5.2' into 5.x
* 5.2: Update direct_submit.rst
2 parents 362b2fd + 4005b8f commit 4f1d4a8

File tree

1 file changed

+18
-0
lines changed

1 file changed

+18
-0
lines changed

form/direct_submit.rst

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,24 @@ control over when exactly your form is submitted and what data is passed to it::
3434
]);
3535
}
3636

37+
The list of fields submitted with the ``submit()`` method must be the same as
38+
the fields defined by the form class. Otherwise, you'll see a form validation error::
39+
40+
public function new(Request $request): Response
41+
{
42+
// ...
43+
44+
if ($request->isMethod('POST')) {
45+
// '$json' represents payload data sent by React/Angular/Vue
46+
// the merge of parameters is needed to submit all form fields
47+
$form->submit(array_merge($json, $request->request->all()));
48+
49+
// ...
50+
}
51+
52+
// ...
53+
}
54+
3755
.. tip::
3856

3957
Forms consisting of nested fields expect an array in

0 commit comments

Comments
 (0)