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

Appearance settings

Commit 36f9dd7

Browse filesBrowse files
committed
minor #7119 Call isSubmitted() before calling isValid() (yceruto)
This PR was squashed before being merged into the 2.7 branch (closes #7119). Discussion ---------- Call isSubmitted() before calling isValid() Forward-compatibility fix Commits ------- 995e2d9 Call isSubmitted() before calling isValid()
2 parents 8336d71 + 995e2d9 commit 36f9dd7
Copy full SHA for 36f9dd7

File tree

Expand file treeCollapse file tree

10 files changed

+13
-13
lines changed
Filter options
Expand file treeCollapse file tree

10 files changed

+13
-13
lines changed

‎components/form.rst

Copy file name to clipboardExpand all lines: components/form.rst
+2-2Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -547,7 +547,7 @@ method:
547547
548548
$form->handleRequest($request);
549549
550-
if ($form->isValid()) {
550+
if ($form->isSubmitted() && $form->isValid()) {
551551
$data = $form->getData();
552552
553553
// ... perform some action, such as saving the data to the database
@@ -573,7 +573,7 @@ method:
573573
574574
$form->handleRequest($request);
575575
576-
if ($form->isValid()) {
576+
if ($form->isSubmitted() && $form->isValid()) {
577577
$data = $form->getData();
578578
579579
// ... perform some action, such as saving the data to the database

‎controller.rst

Copy file name to clipboardExpand all lines: controller.rst
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -391,7 +391,7 @@ For example, imagine you're processing a :doc:`form </forms>` submission::
391391
{
392392
// ...
393393

394-
if ($form->isValid()) {
394+
if ($form->isSubmitted() && $form->isValid()) {
395395
// do some sort of processing
396396

397397
$this->addFlash(

‎controller/upload_file.rst

Copy file name to clipboardExpand all lines: controller/upload_file.rst
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -297,7 +297,7 @@ Now you're ready to use this service in the controller::
297297
{
298298
// ...
299299

300-
if ($form->isValid()) {
300+
if ($form->isSubmitted() && $form->isValid()) {
301301
$file = $product->getBrochure();
302302
$fileName = $this->get('app.brochure_uploader')->upload($file);
303303

‎form/direct_submit.rst

Copy file name to clipboardExpand all lines: form/direct_submit.rst
+3-3Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ submissions::
2222

2323
$form->handleRequest($request);
2424

25-
if ($form->isValid()) {
25+
if ($form->isSubmitted() && $form->isValid()) {
2626
// perform some action...
2727

2828
return $this->redirectToRoute('task_success');
@@ -63,7 +63,7 @@ method, pass the submitted data directly to
6363
if ($request->isMethod('POST')) {
6464
$form->submit($request->request->get($form->getName()));
6565

66-
if ($form->isValid()) {
66+
if ($form->isSubmitted() && $form->isValid()) {
6767
// perform some action...
6868

6969
return $this->redirectToRoute('task_success');
@@ -115,7 +115,7 @@ a convenient shortcut to the previous example::
115115
if ($request->isMethod('POST')) {
116116
$form->submit($request);
117117

118-
if ($form->isValid()) {
118+
if ($form->isSubmitted() && $form->isValid()) {
119119
// perform some action...
120120

121121
return $this->redirectToRoute('task_success');

‎form/dynamic_form_modification.rst

Copy file name to clipboardExpand all lines: form/dynamic_form_modification.rst
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -605,7 +605,7 @@ your application. Assume that you have a sport meetup creation controller::
605605
$meetup = new SportMeetup();
606606
$form = $this->createForm(new SportMeetupType(), $meetup);
607607
$form->handleRequest($request);
608-
if ($form->isValid()) {
608+
if ($form->isSubmitted() && $form->isValid()) {
609609
// ... save the meetup, redirect etc.
610610
}
611611

‎form/form_collections.rst

Copy file name to clipboardExpand all lines: form/form_collections.rst
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -178,7 +178,7 @@ In your controller, you'll now initialize a new instance of ``TaskType``::
178178

179179
$form->handleRequest($request);
180180

181-
if ($form->isValid()) {
181+
if ($form->isSubmitted() && $form->isValid()) {
182182
// ... maybe do some form processing, like saving the Task and Tag objects
183183
}
184184

‎form/multiple_buttons.rst

Copy file name to clipboardExpand all lines: form/multiple_buttons.rst
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ In your controller, use the button's
2222
:method:`Symfony\\Component\\Form\\ClickableInterface::isClicked` method for
2323
querying if the "Save and add" button was clicked::
2424

25-
if ($form->isValid()) {
25+
if ($form->isSubmitted() && $form->isValid()) {
2626
// ... perform some action, such as saving the task to the database
2727

2828
$nextAction = $form->get('saveAndAdd')->isClicked()

‎form/without_class.rst

Copy file name to clipboardExpand all lines: form/without_class.rst
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ an array of the submitted data. This is actually really easy::
2727

2828
$form->handleRequest($request);
2929

30-
if ($form->isValid()) {
30+
if ($form->isSubmitted() && $form->isValid()) {
3131
// data is an array with "name", "email", and "message" keys
3232
$data = $form->getData();
3333
}

‎reference/forms/types/file.rst

Copy file name to clipboardExpand all lines: reference/forms/types/file.rst
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ be used to move the ``attachment`` file to a permanent location::
4747
{
4848
// ...
4949

50-
if ($form->isValid()) {
50+
if ($form->isSubmitted() && $form->isValid()) {
5151
$someNewFilename = ...
5252

5353
$form['attachment']->getData()->move($dir, $someNewFilename);

‎security/acl.rst

Copy file name to clipboardExpand all lines: security/acl.rst
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -132,7 +132,7 @@ Creating an ACL and Adding an ACE
132132
133133
// ... setup $form, and submit data
134134
135-
if ($form->isValid()) {
135+
if ($form->isSubmitted() && $form->isValid()) {
136136
$entityManager = $this->getDoctrine()->getManager();
137137
$entityManager->persist($comment);
138138
$entityManager->flush();

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.