Skip to content
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

Adder and remover sidenote #4253

Merged
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
3 changes: 2 additions & 1 deletion cookbook/form/form_collections.rst
Expand Up @@ -462,7 +462,8 @@ these new ``Tag`` objects easier (especially if you're using Doctrine, which
we talk about next!).

.. caution::

Create **both** methods, otherwise none of them will be used.
Copy link
Member

Choose a reason for hiding this comment

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

Is this correct? If yes, the "and ” in the following paragraph has to be replaced by "or".

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes, this is correct, see https://github.com/symfony/symfony/blob/2.5/src/Symfony/Component/PropertyAccess/PropertyAccessor.php#L589
If one of them is missing, none is used.

I see 2.3 is throwing exceptions in such cases:
https://github.com/symfony/symfony/blob/2.3/src/Symfony/Component/PropertyAccess/PropertyAccessor.php#L409
but I guess this of behaviour has been considered unneeded as default set* and collection->removeElement are used in case of adder / remover absence.

Also the part "If no addTag and removeTag method is found, the form will..." is semantically and logically correct.
~(p^v) <=> ~p v ~v

Copy link
Member

Choose a reason for hiding this comment

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

Hmm, isn't the bold and enough to know this text? If not (readers know things like this better than maintainers), I prefer to add this extra information into the first sentence of this caution. Something along the lines of "You have to create both the addTag and removeTag methods, otherwise the form will still use setTag even if by_reference is set to false."


If no ``addTag`` **and** ``removeTag`` method is found, the form will
still use ``setTag`` even if ``by_reference`` is ``false``. You'll learn
more about the ``removeTag`` method later in this article.
Expand Down