This repository has been archived on 2023-08-20. You can view files and clone it, but cannot push or open issues or pull requests.
symfony/tests/Symfony/Tests/Component/Form
Fabien Potencier baa63b8077 merged branch bschussek/issue1540 (PR #3239)
Commits
-------

9b0245b [Form] Made prefix of adder and remover method configurable. Adders and removers are not called if "by_reference" is disabled.
49d1464 [Form] Implemented MergeCollectionListener which calls addXxx() and removeXxx() in your model if found
7837f50 [Form] Added FormUtil::singularify()

Discussion
----------

[Form] Forms now call addXxx() and removeXxx() in your model

Bug fix: no
Feature addition: yes
Backwards compatibility break: no
Symfony2 tests pass: yes
Fixes the following tickets: #1540
Todo: adapt documentation

![Travis Build Status](https://secure.travis-ci.org/bschussek/symfony.png?branch=issue1540)

Adds functionality for calling `addXxx` and `removeXxx` method in your model. All types returning a collection of values are affected: "collection", "choice" (with multiple selection) and "entity" (with multiple selection).

Example:

    class Article
    {
        public function addTag($tag) { ... }
        public function removeTag($tag) { ... }
        public function getTags($tag) { ... }
    }

And the controller:

    $form = $this->createFormBuilder($article)
        ->add('tags')
        ->getForm();

Upon modifying the form, addTag() and removeTag() are now called appropiately.

---------------------------------------------------------------------------

by stof at 2012-02-01T18:23:49Z

Really great

---------------------------------------------------------------------------

by vicb at 2012-02-01T18:24:04Z

Great !!

Two suggestions:

* make "add" and "remove" configurable,
* introduce a base class for the remove listeners with (final?) `::getSubscribedEvents()` and `::getEventPriorities()`

---------------------------------------------------------------------------

by haswalt at 2012-02-01T18:57:46Z

+1 this

---------------------------------------------------------------------------

by daFish at 2012-02-01T19:54:46Z

+1

---------------------------------------------------------------------------

by michelsalib at 2012-02-01T20:55:37Z

Can wait to have it!
It will save lots of time trying to solve WTF effects and making workarounds.

---------------------------------------------------------------------------

by bschussek at 2012-02-02T09:37:12Z

@vicb: Your first point is done. The second, I don't understand.

---------------------------------------------------------------------------

by stof at 2012-02-02T09:40:50Z

@bschussek your branch conflicts with master according to github

---------------------------------------------------------------------------

by vicb at 2012-02-02T09:52:40Z

@bschussek my point is that I can stand hard-coded priorities which are error prone. A better solution might be to introduce constants (in `FormEvents` / `FormEventPriorities` ?) with meaningful names.

---------------------------------------------------------------------------

by bschussek at 2012-02-02T10:21:52Z

@stof Rebased

@vicb I know, but who is responsible for managing priorities? There is no central entitty that can do this. (btw this is a general problem of the priority system of the EventDispatcher)

@fabpot Ready to merge.

---------------------------------------------------------------------------

by vicb at 2012-02-02T10:23:28Z

@bschussek doesn't each form has is own dispatcher so there is no need for a global registry here, something local to the form could be good enough.
2012-02-02 11:25:38 +01:00
..
Extension merged branch bschussek/issue1540 (PR #3239) 2012-02-02 11:25:38 +01:00
Fixtures [Form] Reverted PR #1758. 2011-07-22 16:42:50 +02:00
Guess fixed CS 2011-06-08 19:56:59 +02:00
Util [Form] Implemented MergeCollectionListener which calls addXxx() and removeXxx() in your model if found 2012-02-02 11:16:21 +01:00
AbstractDivLayoutTest.php [Form] reverted partially previous commit 2011-09-24 16:42:12 +02:00
AbstractExtensionTest.php merged 2.0 2011-10-29 12:01:39 +02:00
AbstractLayoutTest.php merged branch helmer/readonly (PR #3193) 2012-02-02 10:03:00 +01:00
AbstractTableLayoutTest.php Rebased with master, and fixed wrong behavior with proper tests coverage 2011-09-24 10:44:47 +02:00
FormBuilderTest.php [Form] added support for parent of FormBuilder 2012-02-02 10:09:50 +01:00
FormFactoryTest.php merged branch hason/formbuilder (PR #3249) 2012-02-02 10:13:41 +01:00
FormInterface.php fixed CS 2011-06-08 19:56:59 +02:00
FormTest.php merged branch helmer/readonly (PR #3193) 2012-02-02 10:03:00 +01:00
PropertyPathTest.php [Tests] Use proper phpunit assertion functions: "assertTrue", "assertFalse", "assertNull" 2011-08-25 15:41:15 +02:00