Skip to content

Modifications needed to form events chapter #2464

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

Closed
3 of 4 tasks
weaverryan opened this issue Apr 4, 2013 · 5 comments
Closed
3 of 4 tasks

Modifications needed to form events chapter #2464

weaverryan opened this issue Apr 4, 2013 · 5 comments
Labels
actionable Clear and specific issues ready for anyone to take them. bug Form Stalled

Comments

@weaverryan
Copy link
Member

weaverryan commented Apr 4, 2013

The form events chapter just underwent a big addition and facelift in #1842 and #2417. But, it's still not quite right. Here are the needed changes:

  • Simplify the first example - a subscriber is overkill, a listener is easier, and a callback is probably the best approach
  • We need to document every form event and its purpose, what its data is, etc
  • Both the FriendMessage and SportsMeetup examples aren't really completed. They leave out more detail than I like and so aren't copy-and-pastable. This is especially true of SportsMeetup, where I ran out of steam to keep going :). Ideally, all three examples would be more consistent - building up on the same example, not three different examples.
  • I think we need to spend some time on the AJAX experience that's so common when you have one form field that depends on another (i.e. user selects "Country", AJAX request is made to update the "State" field).
@peshi
Copy link

peshi commented Aug 7, 2013

@weaverryan +10

http://symfony.com/doc/current/cookbook/form/dynamic_form_modification.html

"One piece that may still be missing is the client-side updating of your form after the sport is selected. This should be handled by making an AJAX call back to your application. In that controller, you can submit your form, but instead of processing it, simply use the submitted form to render the updated fields. The response from the AJAX call can then be used to update the view."

How is this done?

A full example of how to handle the AJAX call to the application/controller and how to use the submitted form to render the updated fields/form would be very usefull.

also "acme.form.meetup_registration_listener" is missing a : at the end.

weaverryan added a commit that referenced this issue Mar 18, 2014
…bicpi)

This PR was merged into the 2.3 branch.

Discussion
----------

[Cookbook][Dynamic Form Modification] Add AJAX sample

| Q             | A
| ------------- | ---
| Doc fix?      | no
| New docs?     | yes
| Applies to    | 2.3+
| Fixed tickets | #2464 ("AJAX experience")

Do we need a PHP version of the `create.html.twig` which would mainly contain redundant JavaScript?

Commits
-------

a75ad9c Shorten AJAX example
ee33dcd Remove some empty lines from code samples
f47a7c3 Updates & Fixes after public review
2533f29 [Cookbook][Dynamic Form Modification] Add AJAX sample
@tkleinhakisa
Copy link

Hi, i just struggled a bit with form events and dynamic fields.

I was adding fields in the SUBMIT event and even if the field was validated the error was not added to the form. Just moving from SUBMIT to PRE_SUBMIT did the trick.

The requirement for PRE_SUBMIT if your field has constraints could be documented

Thank you

@carsonbot
Copy link
Collaborator

Thank you for this issue.
There has not been a lot of activity here for a while. Has this been resolved?

@carsonbot
Copy link
Collaborator

Friendly ping? Should this still be open? I will close if I don't hear anything.

@wouterj
Copy link
Member

wouterj commented Jan 3, 2021

For a while already, we have an article dedicated to all events: https://symfony.com/doc/current/form/events.html

That fixes the biggest points in this issue, so let's close here. (updating to more real examples is something that applies to many articles, there is no need for an open issue for that imho)

@wouterj wouterj closed this as completed Jan 3, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
actionable Clear and specific issues ready for anyone to take them. bug Form Stalled
Projects
None yet
Development

No branches or pull requests

5 participants