8000 [Form] Entity field in from null after request · Issue #2861 · symfony/symfony · GitHub
[go: up one dir, main page]

Skip to content

[Form] Entity field in from null after request #2861

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

Closed
phpeek opened this issue Dec 13, 2011 · 1 comment
Closed

[Form] Entity field in from null after request #2861

phpeek opened this issue Dec 13, 2011 · 1 comment
Milestone

Comments

@phpeek
Copy link
phpeek commented Dec 13, 2011

I have an entities that look like this:

class Customer
{
private $id;

 private $name;

 private $contact_user;

 private $new_contact_user;

}

class User
{
private $id;

 private $name;

}

Form connected with Customer has a field $new_contact_user of type UserType. Adding new contact user to customer is not required during adding or updating Customer. Whenever i leave UserType form blank i'm getting $new_contact_user as User entity filled with null values. How can I check if UserType form fields were left with blank during request ?

@webmozart
Copy link
Contributor

Is the field with the UserType set to required? If not, AFAIK no new object should be created.

fabpot added a commit that referenced this issue Feb 2, 2012
Commits
-------

bd461e2 [Form] Forms now don't create empty objects anymore if they are completely empty and not required. The empty data for these forms is null.

Discussion
----------

[Form] Forms now don't create empty objects anymore if they are empty and not required

Bug fix: yes
Feature addition: no
Backwards compatibility break: no
Symfony2 tests pass: yes
Fixes the following tickets: #2861
Todo: -

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

If a form (or a nested form) is left completely empty upon submission and is not required, no new data object will be generated anymore. Instead, the form returns null as data.
@fabpot fabpot closed this as completed Feb 2, 2012
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants
0