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

Conversation

kklecho
Copy link
Contributor

@kklecho kklecho commented Sep 20, 2014

Q A
Doc fix? yes
New docs? no
Applies to all
Fixed tickets none

There are cases when you only want either adder or remover, important to know both of them need to be found if any is to work.

| Q             | A
| ------------- | ---
| Doc fix?      | yes
| New docs?     | no
| Applies to    | all
| Fixed tickets | none

There are cases when you only want either adder or remover, important to know both of them need to be found if any is to work.
@@ -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."

Merged both notes into one, in accordance to discussion feedback.
@kklecho
Copy link
Contributor Author

kklecho commented Sep 21, 2014

I'd still add proposed note explicitly. Merged into one paragraph as suggested.

Rationale:
You could infer it from next sentence, but it is focused on informing when setTag is still used. As a reader you try to understand entire concept, you don't run so much targetted tautologic analysis, and it's easy to miss it. Even if you read this fragment several times having your code not working (found out myself :)).

I think it's also because natural, intuitive expectation is adder and remover are separate overrides.

@xabbuh
Copy link
Member

xabbuh commented Nov 18, 2014

@wouterj @weaverryan What do you think about this? From my point of view, this is ready to be merged.

@weaverryan
Copy link
Member

Hey @kshishkin! I think this is a way more clear than before. Thanks so much for this!

@weaverryan weaverryan merged commit 59b932d into symfony:2.3 Nov 20, 2014
weaverryan added a commit that referenced this pull request Nov 20, 2014
This PR was merged into the 2.3 branch.

Discussion
----------

Adder and remover sidenote

| Q             | A
| ------------- | ---
| Doc fix?      | yes
| New docs?     | no
| Applies to    | all
| Fixed tickets | none

There are cases when you only want either adder or remover, important to know both of them need to be found if any is to work.

Commits
-------

59b932d Merging emphasized notes
bdd8325 Adder and remover sidenote
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants