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

Skip to content

Commit a92442a

Browse files
committed
minor #13850 [Form] Update direct_submit.rst (KamilKubicki)
This PR was submitted for the 5.1 branch but it was merged into the 5.2 branch instead. Discussion ---------- [Form] Update direct_submit.rst Updating the rules for payload data submission - payload fields should equal FormType class describing the Form structure <!-- 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 `master` for features of unreleased versions). --> Commits ------- 60f5034 Update direct_submit.rst
2 parents dc6872c + 60f5034 commit a92442a

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

form/direct_submit.rst

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,3 +59,12 @@ control over when exactly your form is submitted and what data is passed to it::
5959

6060
// 'email' and 'username' are added manually to force their validation
6161
$form->submit(array_merge(['email' => null, 'username' => null], $request->request->all()), false);
62+
63+
.. caution::
64+
65+
When submitting a form via a "POST" request and manually submitting the form
66+
with ``submit()``, ensure that list of fields in payload equals the list of validated
67+
fields in FormType class - in other case the form validation will fail.
68+
69+
//'json' represents payload data (used frequently by api client as React/Angular/Vue etc.)
70+
$form->submit(array_merge($json, $request->request->all()));

0 commit comments

Comments
 (0)