8000 Added alternative syntax using getClickedButton() by ThomasLandauer · Pull Request #7931 · symfony/symfony-docs · GitHub
[go: up one dir, main page]

Skip to content

Added alternative syntax using getClickedButton() #7931

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Sep 3, 2017

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
@ThomasLa
8288
ndauer 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
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants
0