8000 [Form] Fixed: The "data" option is taken into account even if it is NULL by webmozart · Pull Request #9388 · symfony/symfony · GitHub
[go: up one dir, main page]

Skip to content

[Form] Fixed: The "data" option is taken into account even if it is NULL #9388

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 28, 2013

Conversation

webmozart
Copy link
Contributor
Q A
Bug fix? yes
New feature? no
BC breaks? no
Deprecations? no
Tests pass? yes
Fixed tickets -
License MIT
Doc PR -

fabpot added a commit that referenced this pull request Oct 28, 2013
…if it is NULL (bschussek)

This PR was merged into the 2.2 branch.

Discussion
----------

[Form] Fixed: The "data" option is taken into account even if it is NULL

| Q             | A
| ------------- | ---
| Bug fix?      | yes
| New feature?  | no
| BC breaks?    | no
| Deprecations? | no
| Tests pass?   | yes
| Fixed tickets | -
| License       | MIT
| Doc PR        | -

Commits
-------

c1a3eb3 [Form] Fixed: The "data" option is taken into account even if it is NULL
@fabpot fabpot merged commit c1a3eb3 into symfony:2.2 Oct 28, 2013
@gnutix
Copy link
Contributor
gnutix commented Nov 12, 2013

This commit causes a BC break on my application.

I have a custom Countries FormType which, by default, set the "data" attribute to the value of the user's country. In some forms, I don't want this pre-filling to happen, so I set the option array('data' => null) in the controller when I create the form. Before, this resulted in the field being pre-filled with the data of the binded object to the form (if there is some), and now the field is not pre-filled anymore.

Any idea how to have the same behavior as before ?

@webmozart
Copy link
Contributor Author

@gnutix Depends on how you build the form. Instead of setting 'data' => null, you could get the builder instance and deactivate data locking:

$formBuilder = $this->get('form.factory')->createBuilder('myform', $entity);
$formBuilder->get('country')->setDataLocked(false);
$form = $formBuilder->getForm();

@gnutix
Copy link
Contributor
gnutix commented Nov 12, 2013

@bschussek Thanks for the answer. setDataLocked(false) works well for some of my forms, not others (which are more complicated). I'll dig it another time. I think this should be documented in the UPGRADE file. WDYT?

@piotrpasich
Copy link

+1

@webmozart
Copy link
Contributor Author

@gnutix You're very welcome to submit a PR for the UPGRADE file! :)

fabpot pushed a commit that referenced this pull request Jan 6, 2014
fabpot added a commit that referenced this pull request Jan 6, 2014
This PR was submitted for the 2.3-dev branch but it was merged into the 2.3 branch instead (closes #9804).

Discussion
----------

[Form] Update UPGRADE-2.3.md to account for #9388

Added documentation for how to correctly pre-fill a form using the form's `data` option.
The "old" and also wrong way of doing it broke with Symfony 2.3.7 (with #9388 to be precise) and this short documentation should help others to fix the problem and do it right.

Commits
-------

5e06535 [Form] Update UPGRADE-2.3.md to account for #9388
fabpot added a commit that referenced this pull request Jan 7, 2014
* 2.3:
  update year on licenses
  rundown and typo fix
  [Process] Fix #9861 : Revert TTY mode
  [Form] Update minimal requirement in composer.json
  Fix Empty translations with Qt files
  Update UPGRADE-2.3.md to account for #9388

Conflicts:
	src/Symfony/Component/Validator/Tests/Constraints/LessThanValidatorTest.php
fabpot added a commit that referenced this pull request Jan 7, 2014
* 2.4:
  udpated LICENSE year
  update year on licenses
  rundown and typo fix
  [Process] Fix #9861 : Revert TTY mode
  [Form] Update minimal requirement in composer.json
  Fix Empty translations with Qt files
  [Console] Fixed command name guessing if an alternative is an alias.
  Update UPGRADE-2.3.md to account for #9388
  [WebProfilerBundle] Fixed profiler toolbar icons for XHTML.
  [BrowserKit] Throw exception on invalid cookie expiration timestamp
  [Propel1Bridge][ModelChoiceList] add exception message for invalid classes
@webmozart webmozart deleted the data-option-null branch January 14, 2014 16:29
ostrolucky pushed a commit to ostrolucky/symfony that referenced this pull request Mar 25, 2018
* 2.3:
  update year on licenses
  rundown and typo fix
  [Process] Fix symfony#9861 : Revert TTY mode
  [Form] Update minimal requirement in composer.json
  Fix Empty translations with Qt files
  Update UPGRADE-2.3.md to account for symfony#9388

Conflicts:
	src/Symfony/Component/Validator/Tests/Constraints/LessThanValidatorTest.php
ostrolucky pushed a commit to ostrolucky/symfony that referenced this pull request Mar 25, 2018
* 2.4:
  udpated LICENSE year
  update year on licenses
  rundown and typo fix
  [Process] Fix symfony#9861 : Revert TTY mode
  [Form] Update minimal requirement in composer.json
  Fix Empty translations with Qt files
  [Console] Fixed command name guessing if an alternative is an alias.
  Update UPGRADE-2.3.md to account for symfony#9388
  [WebProfilerBundle] Fixed profiler toolbar icons for XHTML.
  [BrowserKit] Throw exception on invalid cookie expiration timestamp
  [Propel1Bridge][ModelChoiceList] add exception message for invalid classes
jderusse pushed a commit to jderusse/symfony that referenced this pull request Dec 15, 2020
* 2.4:
  udpated LICENSE year
  update year on licenses
  rundown and typo fix
  [Process] Fix symfony#9861 : Revert TTY mode
  [Form] Update minimal requirement in composer.json
  Fix Empty translations with Qt files
  [Console] Fixed command name guessing if an alternative is an alias.
  Update UPGRADE-2.3.md to account for symfony#9388
  [WebProfilerBundle] Fixed profiler toolbar icons for XHTML.
  [BrowserKit] Throw exception on invalid cookie expiration timestamp
  [Propel1Bridge][ModelChoiceList] add exception message for invalid classes
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
0