Refactor: Dynamic forms cookbook entry #2417

Merged
merged 2 commits into from Apr 4, 2013

Projects

None yet

2 participants

@weaverryan
Symfony member
Q A
Doc fix? yes
New docs? no
Applies to or 2.1+

The dynamic forms cookbook entry was enhanced greatly in #1842. However, it lacks some consistency now, along with a number of other issues. I've done my best here as a first pass at fixing all of this and getting this entry up to the level where it needs to be.

My goal here is to:

1) Get any more obvious issues fixed and merge this in
2) After, create an issue so we can track the remaining things that need to be updated. These include:

  • 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).

Thanks!

@wouterj wouterj commented on an outdated diff Mar 30, 2013
cookbook/form/dynamic_form_modification.rst
-While this example could have used the ``form.post_set_data``
-event just as effectively, by using ``form.pre_set_data`` you guarantee that
-the data being retrieved from the ``Event`` object has in no way been modified
-by any other subscribers or listeners because ``form.pre_set_data`` is the
-first form event dispatched.
+ The ``FormEvents::PRE_SET_DATA`` line actually resolves to the string
+ ``form.pre_set_data``. :class:`Symfony\\Component\\Form\\FormEvents` serves an organizational purpose. It is a centralized location
@wouterj
wouterj Mar 30, 2013

some linebreaks missing here

@weaverryan weaverryan merged commit d9becd2 into 2.1 Apr 4, 2013
@weaverryan weaverryan deleted the dynamic-forms branch Apr 4, 2013
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment