Skip to content

Fixes to cookbook/doctrine/registration_form.rst #3615

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

Conversation

Crushnaut
Copy link
Contributor

As I was working through this example I noticed a few issues. Firstly, no button to submit the registration form is ever specified. Secondly, in the accountController the Response object is included, but not needed. Thirdly, the Request object is required in the code block for the method createAction in the accountController.

Q A
Doc fix? yes
New docs? no
Applies to all (or 2.3+)
Fixed tickets none that I know of

@@ -239,7 +240,7 @@ controller for displaying the registration form::
namespace Acme\AccountBundle\Controller;

use Symfony\Bundle\FrameworkBundle\Controller\Controller;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\HttpFoundation\Request;
Copy link
Member

Choose a reason for hiding this comment

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

this one can be removed completely, since we do not use that object and you will never need it in this example.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

In the next code block you are instructed to add the createAction to the accountController which has the parameter $request as a Request object.

public function createAction(Request $request)

I think it is easier to just include the use statement when specifying the registerAction, but perhaps it would be better to place a note after the createAction code mentioning that you will need to add a use statement for the Request object.

I guess the other option would be to change the line defining the createAction to something like,

public function createAction(\Symfony\Component\HttpFoundation\Request $request)

Copy link
Member

Choose a reason for hiding this comment

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

Ah, missed that one (it was too far below). Thanks for pointing to it.

Our standard is to remove the use statement here and add it at the top of the next code block (the one with createAction):

use Symfony\Component\HttpFoundation\Request;
// ...

public function createAction(Request $request)
{

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Oh that makes sense. Should I cancel this pull request and make up a new one with that change?

Copy link
Member

Choose a reason for hiding this comment

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

No, if you push a new commit with the change to the branch of this PR (fixes_cookbook_doctrine_registration), it'll be updated.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Awesome. Done. Thanks again for the help!

@wouterj
Copy link
Member

wouterj commented Feb 27, 2014

👍 great job testing the code!

@weaverryan
Copy link
Member

Great finds - thanks Phil!

weaverryan added a commit that referenced this pull request Feb 27, 2014
This PR was merged into the 2.3 branch.

Discussion
----------

Fixes to cookbook/doctrine/registration_form.rst

As I was working through this example I noticed a few issues. Firstly, no button to submit the registration form is ever specified. Secondly, in the accountController the Response object is included, but not needed. Thirdly, the Request object is required in the code block for the method createAction in the accountController.

| Q             | A
| ------------- | ---
| Doc fix?      | yes
| New docs?     | no
| Applies to    | all (or 2.3+)
| Fixed tickets | none that I know of

Commits
-------

b56ab13 Made on additional fix as per previous pull request.
adffc6b Fixes to cookbook/doctrine/registration_form.rst
@weaverryan weaverryan merged commit b56ab13 into symfony:2.3 Feb 27, 2014
@Crushnaut Crushnaut deleted the fixes_cookbook_doctrine_registration branch February 27, 2014 22:31
@Crushnaut
Copy link
Contributor Author

I was just reading the code from this tutorial (http://symfony.com/doc/current/cookbook/doctrine/registration_form.html#handling-the-form-submission) and I noticed you don't even need the registerAction method in the controller as createAction does everything that the register action does, plus it handles the form submission. Would it not be better for simplicities sake to just remove the registerAction method and just use the createAction? Or perhaps place a tip bubble at the end of this section with something towards the effect of, "Hey, if you want you can omit the registerAction and just use createAction to handle the GET and POST methods for your form?"

@xabbuh
Copy link
Member

xabbuh commented Mar 3, 2014

@Crushnaut Do you mind creating a new issue for this?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants