Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

[RC][Form] Let null values clear fields in PATCH requests #9146

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

Merged
merged 1 commit into from
Oct 1, 2013
Merged

[RC][Form] Let null values clear fields in PATCH requests #9146

merged 1 commit into from
Oct 1, 2013

Conversation

alex88
Copy link
Contributor

@alex88 alex88 commented Sep 27, 2013

Q A
Bug fix? no
New feature? no
BC breaks? yes
Deprecations? no
Tests pass? yes

I've changed the way form checks wherever or not to submit childs by checking submitted data with array_key_exists and not with just isset.

This way in PATCH requests values are not processed when they are not in array and not also when the value is null. Currently there is no way to null a value with a PATCH request, even passing it null.

This can lead to some BC breaks depending on how users used form in their code.

@webmozart
Copy link
Contributor

Can you please add a test case?

@alex88
Copy link
Contributor Author

alex88 commented Sep 30, 2013

I'm doing a rebase since there are some commits in between

$form->setData($author);
$form->submit(array('lastName' => null), false);

$this->assertNull($author->getLastName());
Copy link
Contributor

Choose a reason for hiding this comment

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

Sorry, I seem to have given too little information here. The current test cases for this functionality are located in CompoundFormTest:85++, so we should also add this test case there. For example:

public function testSubmitForwardsNullIfNotClearMissingButValueIsExplicitlyNull()
{
    $child = $this->getMockForm('firstName');

    $this->form->add($child);

    $child->expects($this->once())
        ->method('submit')
        ->with($this->equalTo(null));

    $this->form->submit(array('firstName' => null), false);
}

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Oh sorry for that! Going to add this too.

@alex88
Copy link
Contributor Author

alex88 commented Oct 1, 2013

Ok Added that test too and rebased

@webmozart
Copy link
Contributor

Awesome, thanks. You can remove the other test. Could you also squash the commits into the first one please?

@alex88
Copy link
Contributor Author

alex88 commented Oct 1, 2013

Rebased and squashed ;)

@alex88
Copy link
Contributor Author

alex88 commented Oct 1, 2013

Are there any guidelines in where to write tests depending on what to test? So next time I write it correctly on first time :)

@fabpot fabpot merged commit f5812c5 into symfony:master Oct 1, 2013
@flip111
Copy link
Contributor

flip111 commented Oct 1, 2013

This might be related to #8412

@webmozart
Copy link
Contributor

@alex88 Thanks! :) The best thing is to check where the modified functionality is currently tested and to add new tests there. If there are multiple tests for some functionality, you should go to the tests for the lowest layer in the architecture (for example, (Simple|Compound)FormTest is preferrable over FormTypeTest, which contains mainly integration tests).

@alex88
Copy link
Contributor Author

alex88 commented Oct 1, 2013

@bschussek thanks for the tip! I'll watch more carefully next time!

@alex88 alex88 deleted the patch-1 branch October 29, 2013 15:27
fabpot added a commit that referenced this pull request Mar 3, 2014
…ra field. (jenkoian)

This PR was squashed before being merged into the 2.3 branch (closes #10251).

Discussion
----------

[Form][2.3] Fixes empty file-inputs getting treated as extra field.

| Q             | A
| ------------- | ---
| Bug fix?      | yes
| New feature?  | no
| BC breaks?    | no
| Deprecations? | no
| Tests pass?   | yes
| Fixed tickets | #8575 (#8575 (comment))
| License       | MIT

Re-applies 968fe23 (PR #8575).

The test for this already exists, it was just this line that got overwritten by eb9f76d#diff-ca5e25b47f3ecc94cd557946aeb486c6L542

To clarify, this is a PR into 2.3 branch - this already exists in 2.4 (and later from this PR: #9146)

Commits
-------

8d99d75 [Form][2.3] Fixes empty file-inputs getting treated as extra field.
fabpot added a commit to symfony/form that referenced this pull request Mar 3, 2014
…ra field. (jenkoian)

This PR was squashed before being merged into the 2.3 branch (closes #10251).

Discussion
----------

[Form][2.3] Fixes empty file-inputs getting treated as extra field.

| Q             | A
| ------------- | ---
| Bug fix?      | yes
| New feature?  | no
| BC breaks?    | no
| Deprecations? | no
| Tests pass?   | yes
| Fixed tickets | #8575 (symfony/symfony#8575 (comment))
| License       | MIT

Re-applies 968fe23 (PR #8575).

The test for this already exists, it was just this line that got overwritten by symfony/symfony@eb9f76d#diff-ca5e25b47f3ecc94cd557946aeb486c6L542

To clarify, this is a PR into 2.3 branch - this already exists in 2.4 (and later from this PR: symfony/symfony#9146)

Commits
-------

8d99d75 [Form][2.3] Fixes empty file-inputs getting treated as extra field.
fabpot added a commit to symfony/form that referenced this pull request Mar 3, 2014
…ra field. (jenkoian)

This PR was squashed before being merged into the 2.3 branch (closes #10251).

Discussion
----------

[Form][2.3] Fixes empty file-inputs getting treated as extra field.

| Q             | A
| ------------- | ---
| Bug fix?      | yes
| New feature?  | no
| BC breaks?    | no
| Deprecations? | no
| Tests pass?   | yes
| Fixed tickets | #8575 (symfony/symfony#8575 (comment))
| License       | MIT

Re-applies 968fe23 (PR #8575).

The test for this already exists, it was just this line that got overwritten by symfony/symfony@eb9f76d#diff-ca5e25b47f3ecc94cd557946aeb486c6L542

To clarify, this is a PR into 2.3 branch - this already exists in 2.4 (and later from this PR: symfony/symfony#9146)

Commits
-------

8d99d75 [Form][2.3] Fixes empty file-inputs getting treated as extra field.
fabpot added a commit to symfony/form that referenced this pull request May 23, 2014
…ra field. (jenkoian)

This PR was squashed before being merged into the 2.3 branch (closes #10251).

Discussion
----------

[Form][2.3] Fixes empty file-inputs getting treated as extra field.

| Q             | A
| ------------- | ---
| Bug fix?      | yes
| New feature?  | no
| BC breaks?    | no
| Deprecations? | no
| Tests pass?   | yes
| Fixed tickets | #8575 (symfony/symfony#8575 (comment))
| License       | MIT

Re-applies 968fe23 (PR #8575).

The test for this already exists, it was just this line that got overwritten by symfony/symfony@eb9f76d#diff-ca5e25b47f3ecc94cd557946aeb486c6L542

To clarify, this is a PR into 2.3 branch - this already exists in 2.4 (and later from this PR: symfony/symfony#9146)

Commits
-------

8d99d75 [Form][2.3] Fixes empty file-inputs getting treated as extra field.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants
Morty Proxy This is a proxified and sanitized view of the page, visit original site.