Skip to content

Conversation

ThomasLandauer
Copy link
Contributor

No description provided.

Or you can get the button's name by using the
:method:`Symfony\\Component\\Form\\Form::getClickedButton` method of the form::
if ('saveAndAdd' === $form->getClickedButton()->getName()) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We need to be careful here. Depending on how the form was submitted getClickedButton() may return null. Then, this example would run into an error as getName() could not be executed.

@ThomasLandauer
Copy link
Contributor Author

@xabbuh Yeah!! That's the very reason why I started to work on this section. I'm addressing the null problem in a separate pull request: #7932

@wouterj wouterj merged commit 22314eb into symfony:2.7 Sep 3, 2017
wouterj added a commit that referenced this pull request Sep 3, 2017
…Landauer, 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()
wouterj added a commit that referenced this pull request Sep 3, 2017
@ThomasLandauer ThomasLandauer deleted the patch-12 branch September 3, 2017 18:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment