-
-
Notifications
You must be signed in to change notification settings - Fork 9.6k
[Form][BC break] Decimal fields cannot be type-hinted as float #32124
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
Comments
Is this the right way to work around the Doctrine's change detection issue in the model side? '8.000' -> '8.000': class Product
{
/**
* @ORM\Column(type="decimal", precision=10, scale=3)
*/
private $price = '0';
public function getPrice(): string
{
return $this->price;
}
public function setPrice(string $price)
{
$this->price = $price;
}
} If we use |
@yceruto Yes, that looks good. If you debug your former code, you should be able to see that the |
…buh) This PR was merged into the 4.3 branch. Discussion ---------- [Form] accept floats for input="string" in NumberType | Q | A | ------------- | --- | Branch? | 4.3 | Bug fix? | yes | New feature? | no | BC breaks? | no | Deprecations? | no | Tests pass? | yes | Fixed tickets | #31905, #32124 | License | MIT | Doc PR | Commits ------- 2abf855 accept floats for input="string" in NumberType
Uh oh!
There was an error while loading. Please reload this page.
Symfony version(s) affected: 4.3
Description
I have the follow entity and field definition:
and a form field whose "type" is being guessed by
DoctrineOrmTypeGuesser
:this works well before 4.3, but after upgrade this app, when the form is being built, this error appears:
Possible Solution
It will depend on the right way of type-hinting
decimal
fields.Even if #30893 helps to solve a real problem with Doctrine's change detection, I think we must fix the BC break, either relaxing the transformation constraint allowing numeric values:
symfony/src/Symfony/Component/Form/Extension/Core/DataTransformer/StringToFloatTransformer.php
Lines 37 to 39 in 030396a
or reverting the change in
DoctrineOrmTypeGuesser
:symfony/src/Symfony/Bridge/Doctrine/Form/DoctrineOrmTypeGuesser.php
Lines 77 to 78 in 030396a
deprecating this default, for later change in 5.0 to
input = string
.WDYT?
The text was updated successfully, but these errors were encountered: