Skip to content

Commit 869ec1f

Browse files
committed
minor #7931 Added alternative syntax using getClickedButton() (ThomasLandauer, javiereguiluz, HeahDude)
This PR was merged into the 2.7 branch. Discussion ---------- Added alternative syntax using getClickedButton() Commits ------- 22314eb minor fix 7ecff64 Minor formatting changes 9417432 Added alternative syntax using getClickedButton()
2 parents 7b42ed2 + 22314eb commit 869ec1f

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

form/multiple_buttons.rst

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,3 +31,12 @@ querying if the "Save and add" button was clicked::
3131

3232
return $this->redirectToRoute($nextAction);
3333
}
34+
35+
Or you can get the button's name by using the
36+
:method:`Symfony\\Component\\Form\\Form::getClickedButton` method of the form::
37+
38+
if ($form->getClickedButton() && 'saveAndAdd' === $form->getClickedButton()->getName()) {
39+
// ...
40+
}
41+
42+

0 commit comments

Comments
 (0)