Skip to content

Commit bd41b74

Browse files
committed
minor #11905 Added example for direct form submit with validation (patrickbussmann)
This PR was submitted for the master branch but it was merged into the 3.4 branch instead (closes #11905). Discussion ---------- Added example for direct form submit with validation See symfony/symfony#25331. I had the same issue. My registration form is filled via an API call and this call contains only filled fields. But when the user is missing all fields its an empty array and then the username and email will not be validated. After I found out that this is the behaviour I want to share this knowledge ;-) Commits ------- c81d30a Added example for direct form submit with validation
2 parents 20fff81 + c81d30a commit bd41b74

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

form/direct_submit.rst

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -89,3 +89,8 @@ method, pass the submitted data directly to
8989
"PATCH" method, the validation extension will only handle the submitted
9090
fields. If the underlying data needs to be validated, this should be done
9191
manually, i.e. using the validator.
92+
93+
When you need validation for some fields you can extend your data array with the required ones so that they will be validated.
94+
i.e.::
95+
96+
$form->submit(array_merge(['email' => null, 'username' => null], $request->request->all()), false);

0 commit comments

Comments
 (0)