-
-
Notifications
You must be signed in to change notification settings - Fork 9.6k
[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
Conversation
Q | A |
---|---|
Bug fix? | yes |
New feature? | no |
BC breaks? | no |
Deprecations? | no |
Tests pass? | yes |
Fixed tickets | - |
License | MIT |
Doc PR | - |
…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
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 ? |
@gnutix Depends on how you build the form. Instead of setting $formBuilder = $this->get('form.factory')->createBuilder('myform', $entity);
$formBuilder->get('country')->setDataLocked(false);
$form = $formBuilder->getForm(); |
@bschussek Thanks for the answer. |
+1 |
@gnutix You're very welcome to submit a PR for the UPGRADE file! :) |
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
* 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
* 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
* 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
* 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
* 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